mirror of
https://github.com/servo/servo.git
synced 2025-09-09 22:48:21 +01:00
Check whether an element is custom in the spec-compliant way (#35960)
* Check whether element is custom in spec-compliant way Signed-off-by: Xiaocheng Hu <xiaochengh.work@gmail.com> * Update tests Signed-off-by: Xiaocheng Hu <xiaochengh.work@gmail.com> --------- Signed-off-by: Xiaocheng Hu <xiaochengh.work@gmail.com>
This commit is contained in:
parent
ea35353e9a
commit
62d6759106
6 changed files with 71 additions and 13 deletions
2
tests/wpt/meta/MANIFEST.json
vendored
2
tests/wpt/meta/MANIFEST.json
vendored
|
@ -612804,7 +612804,7 @@
|
|||
]
|
||||
],
|
||||
"custom-element-reaction-queue.html": [
|
||||
"246b15a0af36cffa0b64f1d57e4208538b92bdd7",
|
||||
"eb8366f2b415894f396da613987982ae41ffe0b6",
|
||||
[
|
||||
null,
|
||||
{}
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
[custom-element-reaction-queue.html]
|
||||
[Upgrading a custom element must not invoke attributeChangedCallback for the attribute that is changed during upgrading]
|
||||
expected: FAIL
|
||||
|
|
@ -83,6 +83,60 @@ test_with_window(function (contentWindow) {
|
|||
assert_connected_log_entry(log[1], element);
|
||||
}, 'Upgrading a custom element must not invoke attributeChangedCallback for the attribute that is changed during upgrading');
|
||||
|
||||
test_with_window(function (contentWindow) {
|
||||
const contentDocument = contentWindow.document;
|
||||
contentDocument.write('<test-element>');
|
||||
|
||||
const element = contentDocument.querySelector('test-element');
|
||||
assert_equals(Object.getPrototypeOf(element), contentWindow.HTMLElement.prototype);
|
||||
|
||||
let log = [];
|
||||
class TestElement extends contentWindow.HTMLElement {
|
||||
constructor() {
|
||||
super();
|
||||
this.remove();
|
||||
log.push(create_constructor_log(this));
|
||||
}
|
||||
connectedCallback(...args) {
|
||||
log.push(create_connected_callback_log(this, ...args));
|
||||
}
|
||||
disconnectedCallback(...args) {
|
||||
log.push(create_disconnected_callback_log(this, ...args));
|
||||
}
|
||||
}
|
||||
contentWindow.customElements.define('test-element', TestElement);
|
||||
assert_equals(Object.getPrototypeOf(element), TestElement.prototype);
|
||||
|
||||
assert_equals(log.length, 2);
|
||||
assert_constructor_log_entry(log[0], element);
|
||||
assert_connected_log_entry(log[1], element);
|
||||
}, 'Upgrading a custom element must not invoke disconnectedCallback if the element is disconnected during upgrading');
|
||||
|
||||
test_with_window(function (contentWindow) {
|
||||
const contentDocument = contentWindow.document;
|
||||
const element = contentDocument.createElement('test-element');
|
||||
assert_equals(Object.getPrototypeOf(element), contentWindow.HTMLElement.prototype);
|
||||
|
||||
let log = [];
|
||||
class TestElement extends contentWindow.HTMLElement {
|
||||
constructor() {
|
||||
super();
|
||||
contentDocument.documentElement.appendChild(this);
|
||||
log.push(create_constructor_log(this));
|
||||
}
|
||||
connectedCallback(...args) {
|
||||
log.push(create_connected_callback_log(this, ...args));
|
||||
}
|
||||
}
|
||||
contentWindow.customElements.define('test-element', TestElement);
|
||||
contentWindow.customElements.upgrade(element);
|
||||
|
||||
assert_equals(Object.getPrototypeOf(element), TestElement.prototype);
|
||||
|
||||
assert_equals(log.length, 1);
|
||||
assert_constructor_log_entry(log[0], element);
|
||||
}, 'Upgrading a disconnected custom element must not invoke connectedCallback if the element is connected during upgrading');
|
||||
|
||||
test_with_window(function (contentWindow) {
|
||||
const contentDocument = contentWindow.document;
|
||||
contentDocument.write('<test-element id="first-element">');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue