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

Fix custom element state setting for new CustomElement() #1309

Merged
merged 1 commit into from
May 31, 2016

Conversation

domenic
Copy link
Member

@domenic domenic commented May 24, 2016

As discussed in #1297, the spec previously did not correctly set custom
element state to "custom" for the case of new CustomElement(). The
correct place to do this is in the HTMLElement constructor (invoked by
the super() call), since that is the last place user agent code is
invoked, and so our last chance to change the state. In practice, this
affects the behavior of the :defined pseudo-class.

Fixes #1297. Also fixes a typo in the same algorithms, where the
variable names "element" and "interface" were accidentally both used.

/cc @dominiccooney @kojiishi

@domenic domenic added the topic: custom elements Relates to custom elements (as defined in DOM and HTML) label May 24, 2016
domenic added a commit to whatwg/dom that referenced this pull request May 24, 2016
As of whatwg/html#1309, this is no longer necessary, as it is taken care of in the Construct(C) step.
@dominiccooney
Copy link

LGTM

As discussed in #1297, the spec previously did not correctly set custom
element state to "custom" for the case of new CustomElement(). The
correct place to do this is in the HTMLElement constructor (invoked by
the super() call), since that is the last place user agent code is
invoked, and so our last chance to change the state. In practice, this
affects the behavior of the :defined pseudo-class.

Fixes #1297. Also fixes a typo in the same algorithms, where the
variable names "element" and "interface" were accidentally both used.
@domenic domenic merged commit 9a49f18 into master May 31, 2016
@domenic domenic deleted the fix-ce-state branch May 31, 2016 22:52
domenic added a commit to whatwg/dom that referenced this pull request May 31, 2016
As of whatwg/html#1309, this is no longer necessary, as it is taken care of in the Construct(C) step.
annevk pushed a commit to whatwg/dom that referenced this pull request Jun 1, 2016
As of whatwg/html#1309, this is no longer necessary, as it is taken care of in the Construct(C) step.
annevk pushed a commit to whatwg/dom that referenced this pull request Jun 1, 2016
As of whatwg/html#1309, this is no longer necessary, as it is taken care of in the Construct(C) step.
domenic added a commit that referenced this pull request Jun 1, 2016
As pointed out in
#1297 (comment), the
setup introduced in #1309 allows custom element reactions to happen
during custom element constructors. This is unavoidable, but the spec
did not account for its consequences, leading to cases where a custom
element reaction would be called twice for the same attribute (or the
same element being connected). By moving these steps to the top of the
algorithm, we ensure that reactions are only enqueued for the state of
the world before the constructor runs, and that any reactions caused by
actions inside the constructor are then taken care of by the usual
mechanisms.

Closes #1297 again.
annevk pushed a commit that referenced this pull request Jun 6, 2016
As pointed out in
#1297 (comment), the
setup introduced in #1309 allows custom element reactions to happen
during custom element constructors. This is unavoidable, but the spec
did not account for its consequences, leading to cases where a custom
element reaction would be called twice for the same attribute (or the
same element being connected). By moving these steps to the top of the
algorithm, we ensure that reactions are only enqueued for the state of
the world before the constructor runs, and that any reactions caused by
actions inside the constructor are then taken care of by the usual
mechanisms.

Closes #1297 again.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: custom elements Relates to custom elements (as defined in DOM and HTML)
Development

Successfully merging this pull request may close these issues.

Custom elements created with "new" are not :defined
2 participants