Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always enqueue an element regardless of callback #4127

Closed
wants to merge 3 commits into from

Conversation

annevk
Copy link
Member

@annevk annevk commented Oct 26, 2018

not contain <var>attributeName</var>, then return.</p></li>
<li><p>If <var>definition</var>'s <span
data-x="concept-custom-element-definition-observed-attributes">observed attributes</span>
does not contain <var>attributeName</var>, then return.</p></li>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this correct? This is still an early return... An alternative would be to set a flag here to only skip the next step, which is a lil ugly, but okay.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WebKit's implementation always enqueues the element regardless of which attribute is observed. But perhaps that's not as bad as connected/disconnected case since the observedAttributes is the only thing that controls whether an attribute change is observed or not.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah okay, so this should not be observable?

Copy link

@rniwa rniwa Oct 29, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It IS observable. When mutating an attribute that's not being observed would invoke custom elements reactions at that point if the mutation was done inside a connected callback of another element, for example.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, right, sigh. Okay, I think in that case we should always enqueue, and add tests for both scenarios.

Copy link

@rniwa rniwa Nov 6, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this would incur quite a bit of performance cost because then every DOM attribute mutation even ones that are not observed would result in the element to be inserted into a custom element reaction queue. I don't think we want to do that.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I was thinking that too. However, it's hard to square that with sometimes making the order of callbacks predictable and sometimes not. Shouldn't we then maintain the status quo of the standard?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with that as long as other browser vendors are okay with it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with this change.
I think the performance penalty by this isn't large.

@annevk
Copy link
Member Author

annevk commented Oct 26, 2018

cc @rniwa

@annevk annevk added topic: custom elements Relates to custom elements (as defined in DOM and HTML) impacts documentation Used by documentation communities, such as MDN, to track changes that impact documentation labels Oct 26, 2018
@annevk
Copy link
Member Author

annevk commented Oct 30, 2018

I've now made it so that it always enqueues and added a slightly modified version of @tomalec's example.

@rniwa are there tests for this already?

cc @tkent-google

source Show resolved Hide resolved
@chrisdavidmills
Copy link

Docs needs recorded on MDN content roadmap — https://trello.com/c/j2MktaWx/133-custom-elements-api

Copy link
Member

@domenic domenic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM as an implementation of the agreed-upon semantics. Some editorial tweaks suggested.

I'd like @rniwa to confirm that this spec matches WebKit's semantics. It's a bit hard to imagine a bug that switches from one algorithm to another that's quite different (e.g. with a new skip variable).

source Show resolved Hide resolved
source Show resolved Hide resolved
source Show resolved Hide resolved
source Show resolved Hide resolved
@annevk
Copy link
Member Author

annevk commented Nov 16, 2018

So per #4127 (review) we're in a bit of a pickle. Options:

  1. Maintain the status quo. Likely the most performant due to early exits, but execution order weirdly depends on what callbacks you care about.
  2. Make a partial change. Likely still somewhat performant and execution order only partially depends on what callbacks you care about. This doesn't seem acceptable.
  3. Make the change as the PR stands today. Unclear how bad this is for performance. It has some support from Chrome, but no support from Apple.

It seems 3 would require some kind of measurement to be done to make everyone comfortable it's okay. I hope everyone agrees 2 isn't worth it.

@rniwa
Copy link

rniwa commented Nov 16, 2018

?? I just said that I'm fine with the change as long as other browser vendors are fine.

@annevk annevk added the needs tests Moving the issue forward requires someone to write tests label Nov 16, 2018
@annevk
Copy link
Member Author

annevk commented Nov 16, 2018

I see, I thought you said you were fine with maintaining the status quo. 😊

Okay, great, if everyone is onboard the main blocker here is tests.

@rniwa
Copy link

rniwa commented Nov 21, 2018

Hm... I'm having second thoughts about this. If we made this change, presumably, all new reaction callback we would add should do the same. But that would mean that we would enqueue a custom element into the reaction queue at timings we currently don't do. That seems like a serious forward compatibility issue to me.

annevk added a commit that referenced this pull request Dec 13, 2018
annevk added a commit that referenced this pull request Dec 13, 2018
@annevk annevk closed this in #4237 Jan 3, 2019
annevk added a commit that referenced this pull request Jan 3, 2019
@annevk annevk deleted the annevk/always-enqueue-element branch January 3, 2019 10:36
alice pushed a commit to alice/html that referenced this pull request Jan 7, 2019
mustaqahmed pushed a commit to mustaqahmed/html that referenced this pull request Feb 15, 2019
mustaqahmed pushed a commit to mustaqahmed/html that referenced this pull request Feb 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
impacts documentation Used by documentation communities, such as MDN, to track changes that impact documentation needs tests Moving the issue forward requires someone to write tests topic: custom elements Relates to custom elements (as defined in DOM and HTML)
Development

Successfully merging this pull request may close these issues.

6 participants