Skip to content

onbeforeremove should tolerate thenables that synchronously resolve #2592

Closed
@dead-claudia

Description

@dead-claudia

Mithril version: v2.0.4 (not new, though)

Browser and OS: All

Project:

Code

const Comp = {
	view: () => m("div"),
	onbeforeremove: () => {
		then(resolve, reject) {
			resolve(delay(100))
		},
	},
}

function delay(ms) {
	return new Promise(resolve => { setTimeout(resolve, ms) })
}

Steps to Reproduce

Expected Behavior

It to operate asynchronously

Current Behavior

It doesn't wait.

Context

We're not honoring the Promises/A+ spec here. And fixing this is as simple as changing these two lines to wrap their this value with Promise.resolve(...).

Metadata

Metadata

Assignees

Labels

Area: CoreFor anything dealing with Mithril core itselfType: BugFor bugs and any other unexpected breakage

Type

No type

Projects

Status

Closed

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions