WebKit Bugzilla
Attachment 340871 Details for
Bug 183583
: connectedCallback called when disconnected
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-183583-20180521212936.patch (text/plain), 4.69 KB, created by
Rob Buis
on 2018-05-21 12:29:38 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Rob Buis
Created:
2018-05-21 12:29:38 PDT
Size:
4.69 KB
patch
obsolete
>Subversion Revision: 232023 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 123deee123a6b480e294825ca702607d9a39748a..4c8dcc5f6ed34eff4e7e1c68e78a58c526795d63 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,23 @@ >+2018-05-21 Rob Buis <rbuis@igalia.com> >+ >+ connectedCallback called when disconnected >+ https://bugs.webkit.org/show_bug.cgi?id=183583 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ In the testcase the appending of the cloned subtree will enqeue >+ a connectedCallback reaction for the connected child custom element. >+ However by the time this is invoked, the reparenting will >+ cause the same child custom element to toggle to being disconnected. >+ >+ To prevent unintuitive behavior, simply make sure the custom element >+ is really connected before invoking connectedCallback. >+ >+ Test: fast/custom-elements/connected-callback.html >+ >+ * dom/CustomElementReactionQueue.cpp: >+ (WebCore::CustomElementReactionQueueItem::invoke): >+ > 2018-05-21 Olivier Blin <olivier.blin@softathome.com> > > [CMake][WebCore] fix sqlite include dir variable >diff --git a/Source/WebCore/dom/CustomElementReactionQueue.cpp b/Source/WebCore/dom/CustomElementReactionQueue.cpp >index 572b3e0fe53fc23f997fd1c0c7637d101418a46c..761819aa2a9943b512e271ff2edef952cb0cf081 100644 >--- a/Source/WebCore/dom/CustomElementReactionQueue.cpp >+++ b/Source/WebCore/dom/CustomElementReactionQueue.cpp >@@ -76,10 +76,12 @@ public: > elementInterface.upgradeElement(element); > break; > case Type::Connected: >- elementInterface.invokeConnectedCallback(element); >+ if (element.isConnected()) >+ elementInterface.invokeConnectedCallback(element); > break; > case Type::Disconnected: >- elementInterface.invokeDisconnectedCallback(element); >+ if (!element.isConnected()) >+ elementInterface.invokeDisconnectedCallback(element); > break; > case Type::Adopted: > elementInterface.invokeAdoptedCallback(element, *m_oldDocument, *m_newDocument); >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index e4bc3f0d7f9e685c0ff3a1ed81789cadf22daa6b..2704f819ded2385a9e19835cd07e58bce269d411 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,13 @@ >+2018-05-21 Rob Buis <rbuis@igalia.com> >+ >+ connectedCallback called when disconnected >+ https://bugs.webkit.org/show_bug.cgi?id=183583 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * fast/custom-elements/connected-callback-expected.txt: Added. >+ * fast/custom-elements/connected-callback.html: Added. >+ > 2018-05-20 Emilio Cobos Ãlvarez <emilio@crisal.io> > > Update CSSOM WPT tests. >diff --git a/LayoutTests/fast/custom-elements/connected-callback-expected.txt b/LayoutTests/fast/custom-elements/connected-callback-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..a6a06ae36632b07fee02633b2efeffcf17d5948c >--- /dev/null >+++ b/LayoutTests/fast/custom-elements/connected-callback-expected.txt >@@ -0,0 +1,3 @@ >+ >+PASS connectedCallback should not be called when the custom element is not connected. >+ >diff --git a/LayoutTests/fast/custom-elements/connected-callback.html b/LayoutTests/fast/custom-elements/connected-callback.html >new file mode 100644 >index 0000000000000000000000000000000000000000..960401c497b419f572300b1f20bb332331b5f9cd >--- /dev/null >+++ b/LayoutTests/fast/custom-elements/connected-callback.html >@@ -0,0 +1,41 @@ >+<!doctype html> >+<html> >+<head> >+<script src="../../resources/testharness.js"></script> >+<script src="../../resources/testharnessreport.js"></script> >+</head> >+<body> >+<script> >+class Parenter extends HTMLElement { >+ connectedCallback() { >+ const div = this.ownerDocument.createElement('div'); >+ while (this.firstChild) { >+ div.appendChild(this.firstChild); >+ } >+ this.appendChild(div); >+ } >+} >+customElements.define('x-parenter', Parenter); >+ >+class Child extends HTMLElement { >+ connectedCallback() { >+ assert_true(this.isConnected); >+ } >+ disconnectedCallback() { >+ assert_false(this.isConnected); >+ } >+} >+customElements.define('x-child', Child); >+ >+function fetchDocument(url) { >+ var parser = new DOMParser(); >+ return parser.parseFromString(`<x-parenter><x-child></x-child></x-parenter>`, 'text/html'); >+} >+test(function() { >+ const doc = fetchDocument() >+ const resultBody = document.importNode(doc.body, true); >+ document.body.appendChild(resultBody.firstChild); >+}, "connectedCallback should not be called when the custom element is not connected."); >+</script> >+</body> >+</html>
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
rniwa
:
review-
ews-watchlist
:
commit-queue-
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 183583
:
335654
| 340871 |
340875