Prevent infinite recursion when upgrading custom elements#5126
Prevent infinite recursion when upgrading custom elements#5126
Conversation
With this CL, recursive custom element constructions are no
longer allowed. I.e. this will now only run the constructor once:
class extends HTMLElement {
constructor() {
super();
customElements.upgrade(this);
}
}
Previously, the code and spec had a bug which caused the above
code snippet to infinitely recurse. In [1] the spec has changed,
to set the custom element state to kCustom earlier in the process,
so that recursive calls can properly early-out at step #1 (of [2]).
[1] whatwg/html#5126
[2] https://html.spec.whatwg.org/multipage/custom-elements.html#upgrades
Bug: 966472
Change-Id: I76e88c0b70132eee2482c304ef9e727ae1fe8fc7
|
|
||
| <li><p>Set <var>element</var>'s <span>custom element state</span> to "<code | ||
| data-x="">custom</code>".</p></li> | ||
|
|
There was a problem hiding this comment.
This will make it so that custom element's state can move from "custom" to "failed". I don't think we currently allow that that would be strange and might pose a problem elsewhere. We may need to introduce a new state like "upgrading", and reject upgrading of an element in such a state instead.
There was a problem hiding this comment.
I guess this would be observable if you do this.matches(":defined") inside the constructor? You want to ensure that keeps being false, I take it?
There was a problem hiding this comment.
Right. We want to make sure once a custom element has reached :defined, then it never goes back into :undefined state. Since that would be strange & confusing; it could even cause some compatibility issues with existing content that relies on this invariant today.
There was a problem hiding this comment.
OK, I've reworked this to hold, although I did it by just using the "failed" state instead of introducing a new state.
@mfreed7 can you be sure to capture this .matches(":defined") issue in your test case? And also your review would be appreciated since this deviates a bit from what we discussed in #5118.
@rniwa, does this LGTY?
There was a problem hiding this comment.
@domenic Sorry I missed your comment before posting mine above. I like the new change - saves a bit in node. And it appears to work correctly as you've written it. I added a WPT test for this.matches(":defined") within the constructor. Thanks!
There was a problem hiding this comment.
FYI, the chrome CL is ready, just waiting for this PR to land.
With this CL, recursive custom element constructions are no
longer allowed. I.e. this will now only run the constructor once:
class extends HTMLElement {
constructor() {
super();
customElements.upgrade(this);
}
}
Previously, the code and spec had a bug which caused the above
code snippet to infinitely recurse. In [1] the spec has changed,
to set the custom element state to kCustom earlier in the process,
so that recursive calls can properly early-out at step #1 (of [2]).
[1] whatwg/html#5126
[2] https://html.spec.whatwg.org/multipage/custom-elements.html#upgrades
Bug: 966472
Change-Id: I76e88c0b70132eee2482c304ef9e727ae1fe8fc7
With this CL, recursive custom element constructions are no
longer allowed. I.e. this will now only run the constructor once:
class extends HTMLElement {
constructor() {
super();
customElements.upgrade(this);
}
}
Previously, the code and spec had a bug which caused the above
code snippet to infinitely recurse. In [1] the spec has changed,
to set the custom element state to kCustom earlier in the process,
so that recursive calls can properly early-out at step #1 (of [2]).
[1] whatwg/html#5126
[2] https://html.spec.whatwg.org/multipage/custom-elements.html#upgrades
Bug: 966472
Change-Id: I76e88c0b70132eee2482c304ef9e727ae1fe8fc7
With this CL, recursive custom element constructions are no
longer allowed. I.e. this will now only run the constructor once:
class extends HTMLElement {
constructor() {
super();
customElements.upgrade(this);
}
}
Previously, the code and spec had a bug which caused the above
code snippet to infinitely recurse. In [1] the spec has changed,
to set the custom element state to kCustom earlier in the process,
so that recursive calls can properly early-out at step #1 (of [2]).
[1] whatwg/html#5126
[2] https://html.spec.whatwg.org/multipage/custom-elements.html#upgrades
Bug: 966472
Change-Id: I76e88c0b70132eee2482c304ef9e727ae1fe8fc7
With this CL, recursive custom element constructions are no
longer allowed. I.e. this will now only run the constructor once:
class extends HTMLElement {
constructor() {
super();
customElements.upgrade(this);
}
}
Previously, the code and spec had a bug which caused the above
code snippet to infinitely recurse. In [1] the spec has changed,
to set the custom element state to kCustom earlier in the process,
so that recursive calls can properly early-out at step #1 (of [2]).
[1] whatwg/html#5126
[2] https://html.spec.whatwg.org/multipage/custom-elements.html#upgrades
Bug: 966472
Change-Id: I76e88c0b70132eee2482c304ef9e727ae1fe8fc7
With this CL, recursive custom element constructions are no
longer allowed. I.e. this will now only run the constructor once:
class extends HTMLElement {
constructor() {
super();
customElements.upgrade(this);
}
}
Previously, the code and spec had a bug which caused the above
code snippet to infinitely recurse. In [1] the spec has changed,
to set the custom element state to kCustom earlier in the process,
so that recursive calls can properly early-out at step #1 (of [2]).
[1] whatwg/html#5126
[2] https://html.spec.whatwg.org/multipage/custom-elements.html#upgrades
Bug: 966472
Change-Id: I76e88c0b70132eee2482c304ef9e727ae1fe8fc7
With this CL, recursive custom element constructions are no
longer allowed. I.e. this will now only run the constructor once:
class extends HTMLElement {
constructor() {
super();
customElements.upgrade(this);
}
}
Previously, the code and spec had a bug which caused the above
code snippet to infinitely recurse. In [1] the spec has changed,
to set the custom element state to kCustom earlier in the process,
so that recursive calls can properly early-out at step #1 (of [2]).
[1] whatwg/html#5126
[2] https://html.spec.whatwg.org/multipage/custom-elements.html#upgrades
Bug: 966472
Change-Id: I76e88c0b70132eee2482c304ef9e727ae1fe8fc7
With this CL, recursive custom element constructions are no
longer allowed. I.e. this will now only run the constructor once:
class extends HTMLElement {
constructor() {
super();
customElements.upgrade(this);
}
}
Previously, the code and spec had a bug which caused the above
code snippet to infinitely recurse. In [1] the spec has changed,
to set the custom element state to a new state called "upgrading"
before the constructor is called. With this change in place,
recursive calls can properly early-out at step #1 (of [2]).
[1] whatwg/html#5126
[2] https://html.spec.whatwg.org/multipage/custom-elements.html#upgrades
Bug: 966472
Change-Id: I76e88c0b70132eee2482c304ef9e727ae1fe8fc7
With this CL, recursive custom element constructions are no
longer allowed. I.e. this will now only run the constructor once:
class extends HTMLElement {
constructor() {
super();
customElements.upgrade(this);
}
}
Previously, the code and spec had a bug which caused the above
code snippet to infinitely recurse. In [1] the spec has changed,
to set the custom element state to "failed" before the constructor
is called. With this change in place, recursive calls will
early-out at step #2 (of [2]), and avoid the recursion.
[1] whatwg/html#5126
[2] https://html.spec.whatwg.org/multipage/custom-elements.html#upgrades
Bug: 966472
Change-Id: I76e88c0b70132eee2482c304ef9e727ae1fe8fc7
With this CL, recursive custom element constructions are no
longer allowed. I.e. this will now only run the constructor once:
class extends HTMLElement {
constructor() {
super();
customElements.upgrade(this);
}
}
Previously, the code and spec had a bug which caused the above
code snippet to infinitely recurse. In [1] the spec has changed,
to set the custom element state to "failed" before the constructor
is called. With this change in place, recursive calls will
early-out at step #2 (of [2]), and avoid the recursion.
[1] whatwg/html#5126
[2] https://html.spec.whatwg.org/multipage/custom-elements.html#upgrades
Bug: 966472
Change-Id: I76e88c0b70132eee2482c304ef9e727ae1fe8fc7
|
Sorry, I know I have to review this PR. Hoping to do that in the next few days. |
|
Any objections to me landing this change in Chromium now, prior to this PR landing? It seems rather safe - I doubt anyone was depending on the prior infinite recursion behavior. And if we end up changing the details of exactly how the recursion is prevented, we can land that as a subsequent change in code. |
|
No objections, please land! We need multi-implementer support to land in the spec, which is tricky over the holidays, but that shouldn't block implementations. |
|
Thanks! |
With this CL, recursive custom element constructions are no
longer allowed. I.e. this will now only run the constructor once:
class extends HTMLElement {
constructor() {
super();
customElements.upgrade(this);
}
}
Previously, the code and spec had a bug which caused the above
code snippet to infinitely recurse. In [1] the spec has changed,
to set the custom element state to "failed" before the constructor
is called. With this change in place, recursive calls will
early-out at step #2 (of [2]), and avoid the recursion.
[1] whatwg/html#5126
[2] https://html.spec.whatwg.org/multipage/custom-elements.html#upgrades
Bug: 966472
Change-Id: I76e88c0b70132eee2482c304ef9e727ae1fe8fc7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1931644
Reviewed-by: Kent Tamura <tkent@chromium.org>
Commit-Queue: Mason Freed <masonfreed@chromium.org>
Auto-Submit: Mason Freed <masonfreed@chromium.org>
Cr-Commit-Position: refs/heads/master@{#727841}
With this CL, recursive custom element constructions are no
longer allowed. I.e. this will now only run the constructor once:
class extends HTMLElement {
constructor() {
super();
customElements.upgrade(this);
}
}
Previously, the code and spec had a bug which caused the above
code snippet to infinitely recurse. In [1] the spec has changed,
to set the custom element state to "failed" before the constructor
is called. With this change in place, recursive calls will
early-out at step #2 (of [2]), and avoid the recursion.
[1] whatwg/html#5126
[2] https://html.spec.whatwg.org/multipage/custom-elements.html#upgrades
Bug: 966472
Change-Id: I76e88c0b70132eee2482c304ef9e727ae1fe8fc7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1931644
Reviewed-by: Kent Tamura <tkent@chromium.org>
Commit-Queue: Mason Freed <masonfreed@chromium.org>
Auto-Submit: Mason Freed <masonfreed@chromium.org>
Cr-Commit-Position: refs/heads/master@{#727841}
Implement CustomElementRegistry.upgrade <!-- Please describe your changes on the following line: --> An additional small change will be needed if whatwg/html#5126 lands, which will pass an infinite recursion test this is currently failing in custom-elements/upgrading.html (right now the test is asking for behavior that isn't in the spec). The remaining test in custom-elements/custom-element-registry/upgrade.html is because it needs shadow DOM. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #24989 <!-- Either: --> - [X] There are tests for these changes <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Implement CustomElementRegistry.upgrade <!-- Please describe your changes on the following line: --> An additional small change will be needed if whatwg/html#5126 lands, which will pass an infinite recursion test this is currently failing in custom-elements/upgrading.html (right now the test is asking for behavior that isn't in the spec). The remaining test in custom-elements/custom-element-registry/upgrade.html is because it needs shadow DOM. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #24989 <!-- Either: --> - [X] There are tests for these changes <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
…uctions, a=testonly
Automatic update from web-platform-tests
Disallow recursive custom element constructions
With this CL, recursive custom element constructions are no
longer allowed. I.e. this will now only run the constructor once:
class extends HTMLElement {
constructor() {
super();
customElements.upgrade(this);
}
}
Previously, the code and spec had a bug which caused the above
code snippet to infinitely recurse. In [1] the spec has changed,
to set the custom element state to "failed" before the constructor
is called. With this change in place, recursive calls will
early-out at step #2 (of [2]), and avoid the recursion.
[1] whatwg/html#5126
[2] https://html.spec.whatwg.org/multipage/custom-elements.html#upgrades
Bug: 966472
Change-Id: I76e88c0b70132eee2482c304ef9e727ae1fe8fc7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1931644
Reviewed-by: Kent Tamura <tkent@chromium.org>
Commit-Queue: Mason Freed <masonfreed@chromium.org>
Auto-Submit: Mason Freed <masonfreed@chromium.org>
Cr-Commit-Position: refs/heads/master@{#727841}
--
wpt-commits: 4f24cabbe1f503f3daf8cf0834f4fb1a032f31bc
wpt-pr: 20465
…uctions, a=testonly
Automatic update from web-platform-tests
Disallow recursive custom element constructions
With this CL, recursive custom element constructions are no
longer allowed. I.e. this will now only run the constructor once:
class extends HTMLElement {
constructor() {
super();
customElements.upgrade(this);
}
}
Previously, the code and spec had a bug which caused the above
code snippet to infinitely recurse. In [1] the spec has changed,
to set the custom element state to "failed" before the constructor
is called. With this change in place, recursive calls will
early-out at step mykmelez#2 (of [2]), and avoid the recursion.
[1] whatwg/html#5126
[2] https://html.spec.whatwg.org/multipage/custom-elements.html#upgrades
Bug: 966472
Change-Id: I76e88c0b70132eee2482c304ef9e727ae1fe8fc7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1931644
Reviewed-by: Kent Tamura <tkent@chromium.org>
Commit-Queue: Mason Freed <masonfreed@chromium.org>
Auto-Submit: Mason Freed <masonfreed@chromium.org>
Cr-Commit-Position: refs/heads/master@{#727841}
--
wpt-commits: 4f24cabbe1f503f3daf8cf0834f4fb1a032f31bc
wpt-pr: 20465
annevk
left a comment
There was a problem hiding this comment.
Editorially this looks good to me, but left some optional suggestions.
| </ol> | ||
|
|
||
| <p class="note">If the above steps threw an exception, then <var>element</var>'s <span>custom | ||
| element state</span> will remain "<code data-x="">failed</code>".</p> |
There was a problem hiding this comment.
I like this more as a note, as it's more just reassuring you that nothing changed, instead of asserting something...
| return.</p> | ||
| <li id="concept-upgrade-an-element-early-exit"> | ||
| <p>If <var>element</var>'s <span>custom element state</span> is not "<code | ||
| data-x="">undefined</code>" or "<code data-x="">uncustomized</code>", then return.</p> |
There was a problem hiding this comment.
Curious, any reason not to go with the positive check here (failed or custom)?
There was a problem hiding this comment.
I remember waffling on this a few times, especially when I was considering adding a new state. I'm still not sure what is best, but I guess the current PR feels a little better, because it's basically saying "If you're not in an upgradable state, then fail". The positive check is more like "If you are in an un-upgradable state, then fail", which communicates the intent slightly less well, in my opinion.
Prevent infinite recursion when upgrading custom elements <!-- Please describe your changes on the following line: --> The spec and tests were out of sync when I implemented #25410 and I mentioned I'd have an extra detail to attend to if whatwg/html#5126 landed; it did, and I did, and a couple test cases pass. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix two WPT test cases, see test metadata in commit <!-- Either: --> - [X] There are tests for these changes <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Prevent infinite recursion when upgrading custom elements <!-- Please describe your changes on the following line: --> The spec and tests were out of sync when I implemented #25410 and I mentioned I'd have an extra detail to attend to if whatwg/html#5126 landed; it did, and I did, and a couple test cases pass. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix two WPT test cases, see test metadata in commit <!-- Either: --> - [X] There are tests for these changes <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Prevent infinite recursion when upgrading custom elements <!-- Please describe your changes on the following line: --> The spec and tests were out of sync when I implemented #25410 and I mentioned I'd have an extra detail to attend to if whatwg/html#5126 landed; it did, and I did, and a couple test cases pass. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix two WPT test cases, see test metadata in commit <!-- Either: --> - [X] There are tests for these changes <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Prevent infinite recursion when upgrading custom elements <!-- Please describe your changes on the following line: --> The spec and tests were out of sync when I implemented #25410 and I mentioned I'd have an extra detail to attend to if whatwg/html#5126 landed; it did, and I did, and a couple test cases pass. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix two WPT test cases, see test metadata in commit <!-- Either: --> - [X] There are tests for these changes <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Prevent infinite recursion when upgrading custom elements <!-- Please describe your changes on the following line: --> The spec and tests were out of sync when I implemented #25410 and I mentioned I'd have an extra detail to attend to if whatwg/html#5126 landed; it did, and I did, and a couple test cases pass. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix two WPT test cases, see test metadata in commit <!-- Either: --> - [X] There are tests for these changes <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Prevent infinite recursion when upgrading custom elements <!-- Please describe your changes on the following line: --> The spec and tests were out of sync when I implemented #25410 and I mentioned I'd have an extra detail to attend to if whatwg/html#5126 landed; it did, and I did, and a couple test cases pass. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix two WPT test cases, see test metadata in commit <!-- Either: --> - [X] There are tests for these changes <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Prevent infinite recursion when upgrading custom elements <!-- Please describe your changes on the following line: --> The spec and tests were out of sync when I implemented #25410 and I mentioned I'd have an extra detail to attend to if whatwg/html#5126 landed; it did, and I did, and a couple test cases pass. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix two WPT test cases, see test metadata in commit <!-- Either: --> - [X] There are tests for these changes <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
…ts; r=smaug See whatwg/html#5126. Differential Revision: https://phabricator.services.mozilla.com/D60848
…ts; r=smaug See whatwg/html#5126. Differential Revision: https://phabricator.services.mozilla.com/D60848 --HG-- extra : moz-landing-system : lando
…ts; r=smaug See whatwg/html#5126. Differential Revision: https://phabricator.services.mozilla.com/D60848 UltraBlame original commit: 687c61a5b2642d36bc7e6461bbc846fea5479e30
…ts; r=smaug See whatwg/html#5126. Differential Revision: https://phabricator.services.mozilla.com/D60848 UltraBlame original commit: 687c61a5b2642d36bc7e6461bbc846fea5479e30
…changed during upgrading In https://dom.spec.whatwg.org/#handle-attribute-changes, the attributeChangedCallback reaction is enqueued only if the custom-element-state is customized. And the assumption of "custom-element-definition is only available on the element whose custom-element-state is customized" is no longer true after bug 1610054 along with the spec changings in whatwg/html#5126. Differential Revision: https://phabricator.services.mozilla.com/D71027 bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1629761 gecko-commit: a8129abc4c2d5efca1c694803ea43550f39fd7a0 gecko-integration-branch: autoland gecko-reviewers: smaug
…ibute that is changed during upgrading; r=smaug In https://dom.spec.whatwg.org/#handle-attribute-changes, the attributeChangedCallback reaction is enqueued only if the custom-element-state is customized. And the assumption of "custom-element-definition is only available on the element whose custom-element-state is customized" is no longer true after bug 1610054 along with the spec changings in whatwg/html#5126. Differential Revision: https://phabricator.services.mozilla.com/D71027 --HG-- extra : moz-landing-system : lando
…ibute that is changed during upgrading; r=smaug In https://dom.spec.whatwg.org/#handle-attribute-changes, the attributeChangedCallback reaction is enqueued only if the custom-element-state is customized. And the assumption of "custom-element-definition is only available on the element whose custom-element-state is customized" is no longer true after bug 1610054 along with the spec changings in whatwg/html#5126. Differential Revision: https://phabricator.services.mozilla.com/D71027
…changed during upgrading In https://dom.spec.whatwg.org/#handle-attribute-changes, the attributeChangedCallback reaction is enqueued only if the custom-element-state is customized. And the assumption of "custom-element-definition is only available on the element whose custom-element-state is customized" is no longer true after bug 1610054 along with the spec changings in whatwg/html#5126. Differential Revision: https://phabricator.services.mozilla.com/D71027 bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1629761 gecko-commit: a8129abc4c2d5efca1c694803ea43550f39fd7a0 gecko-integration-branch: autoland gecko-reviewers: smaug
…ibute that is changed during upgrading; r=smaug a=RyanVM In https://dom.spec.whatwg.org/#handle-attribute-changes, the attributeChangedCallback reaction is enqueued only if the custom-element-state is customized. And the assumption of "custom-element-definition is only available on the element whose custom-element-state is customized" is no longer true after bug 1610054 along with the spec changings in whatwg/html#5126. Differential Revision: https://phabricator.services.mozilla.com/D71027
…ibute that is changed during upgrading; r=smaug a=RyanVM In https://dom.spec.whatwg.org/#handle-attribute-changes, the attributeChangedCallback reaction is enqueued only if the custom-element-state is customized. And the assumption of "custom-element-definition is only available on the element whose custom-element-state is customized" is no longer true after bug 1610054 along with the spec changings in whatwg/html#5126. Differential Revision: https://phabricator.services.mozilla.com/D71027
…uctions, a=testonly
Automatic update from web-platform-tests
Disallow recursive custom element constructions
With this CL, recursive custom element constructions are no
longer allowed. I.e. this will now only run the constructor once:
class extends HTMLElement {
constructor() {
super();
customElements.upgrade(this);
}
}
Previously, the code and spec had a bug which caused the above
code snippet to infinitely recurse. In [1] the spec has changed,
to set the custom element state to "failed" before the constructor
is called. With this change in place, recursive calls will
early-out at step #2 (of [2]), and avoid the recursion.
[1] whatwg/html#5126
[2] https://html.spec.whatwg.org/multipage/custom-elements.html#upgrades
Bug: 966472
Change-Id: I76e88c0b70132eee2482c304ef9e727ae1fe8fc7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1931644
Reviewed-by: Kent Tamura <tkent@chromium.org>
Commit-Queue: Mason Freed <masonfreed@chromium.org>
Auto-Submit: Mason Freed <masonfreed@chromium.org>
Cr-Commit-Position: refs/heads/master@{#727841}
--
wpt-commits: 4f24cabbe1f503f3daf8cf0834f4fb1a032f31bc
wpt-pr: 20465
…ts; r=smaug See whatwg/html#5126. Differential Revision: https://phabricator.services.mozilla.com/D60848
…ibute that is changed during upgrading; r=smaug In https://dom.spec.whatwg.org/#handle-attribute-changes, the attributeChangedCallback reaction is enqueued only if the custom-element-state is customized. And the assumption of "custom-element-definition is only available on the element whose custom-element-state is customized" is no longer true after bug 1610054 along with the spec changings in whatwg/html#5126. Differential Revision: https://phabricator.services.mozilla.com/D71027
With this CL, recursive custom element constructions are no
longer allowed. I.e. this will now only run the constructor once:
class extends HTMLElement {
constructor() {
super();
customElements.upgrade(this);
}
}
Previously, the code and spec had a bug which caused the above
code snippet to infinitely recurse. In [1] the spec has changed,
to set the custom element state to "failed" before the constructor
is called. With this change in place, recursive calls will
early-out at step #2 (of [2]), and avoid the recursion.
[1] whatwg/html#5126
[2] https://html.spec.whatwg.org/multipage/custom-elements.html#upgrades
Bug: 966472
Change-Id: I76e88c0b70132eee2482c304ef9e727ae1fe8fc7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1931644
Reviewed-by: Kent Tamura <tkent@chromium.org>
Commit-Queue: Mason Freed <masonfreed@chromium.org>
Auto-Submit: Mason Freed <masonfreed@chromium.org>
Cr-Commit-Position: refs/heads/master@{#727841}
Fixes #5118.
(See WHATWG Working Mode: Changes for more details.)
@rniwa @smaug---- can you give a quick +1? This is just a bugfix in my opinion.
@mfreed7 can you write tests for this as part of the Chromium fix?
/custom-elements.html ( diff )