aboutsummaryrefslogtreecommitdiffstats
path: root/components/script
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2019-12-23 19:44:15 -0500
committerGitHub <noreply@github.com>2019-12-23 19:44:15 -0500
commit8791849291b116c7afedebe448ca8b209a8d7531 (patch)
tree77236418863f1c6841f9735ad59170f7a4baf8f7 /components/script
parent85ad53c42b918ca836e1e97deb8582ae987b30e5 (diff)
parent14d278ff1ce87bb628850729ee1e46894290e8bf (diff)
downloadservo-8791849291b116c7afedebe448ca8b209a8d7531.tar.gz
servo-8791849291b116c7afedebe448ca8b209a8d7531.zip
Auto merge of #25367 - pshaughn:ce_undefined_is, r=jdm
apply is: to Document.createElement even when name isn't registered yet The "is" option to Document.createElement should be respected even when the name hasn't been registered yet, in which case the name gets looked up again at the time the element should be upgraded. This change does that. I'm now seeing a few test timeouts that aren't in the metadata, but I suspect they're slowness on my local configuration and not actual breakage. --- <!-- 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 #25009 fix #24997 and fix #24998 <!-- Either: --> - [X] There are tests for these changes OR <!-- 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. -->
Diffstat (limited to 'components/script')
-rw-r--r--components/script/dom/create.rs19
-rw-r--r--components/script/dom/customelementregistry.rs37
2 files changed, 37 insertions, 19 deletions
diff --git a/components/script/dom/create.rs b/components/script/dom/create.rs
index e992a8707dd..c45e4286992 100644
--- a/components/script/dom/create.rs
+++ b/components/script/dom/create.rs
@@ -189,14 +189,21 @@ fn create_html_element(
}
}
- // Steps 7.1-7.2
+ // Steps 7.1-7.3
let result = create_native_html_element(name.clone(), prefix, document, creator);
+ match is {
+ Some(is) => {
+ result.set_is(is);
+ result.set_custom_element_state(CustomElementState::Undefined);
+ },
+ None => {
+ if is_valid_custom_element_name(&*name.local) {
+ result.set_custom_element_state(CustomElementState::Undefined);
+ }
+ },
+ };
- // Step 7.3
- if is_valid_custom_element_name(&*name.local) || is.is_some() {
- result.set_custom_element_state(CustomElementState::Undefined);
- }
-
+ // Step 8
result
}
diff --git a/components/script/dom/customelementregistry.rs b/components/script/dom/customelementregistry.rs
index 7b4229835e2..dbeacdc7ebb 100644
--- a/components/script/dom/customelementregistry.rs
+++ b/components/script/dom/customelementregistry.rs
@@ -581,7 +581,9 @@ pub fn upgrade_element(definition: Rc<CustomElementDefinition>, element: &Elemen
return;
}
- // Step 3
+ // Step 3 happens later to save having to undo it in an exception
+
+ // Step 4
for attr in element.attrs().iter() {
let local_name = attr.local_name().clone();
let value = DOMString::from(&**attr.value());
@@ -593,7 +595,7 @@ pub fn upgrade_element(definition: Rc<CustomElementDefinition>, element: &Elemen
);
}
- // Step 4
+ // Step 5
if element.is_connected() {
ScriptThread::enqueue_callback_reaction(
element,
@@ -602,44 +604,51 @@ pub fn upgrade_element(definition: Rc<CustomElementDefinition>, element: &Elemen
);
}
- // Step 5
+ // Step 6
definition
.construction_stack
.borrow_mut()
.push(ConstructionStackEntry::Element(DomRoot::from_ref(element)));
- // Step 7
+ // Steps 7-8, successful case
let result = run_upgrade_constructor(&definition.constructor, element);
+ // "regardless of whether the above steps threw an exception" step
definition.construction_stack.borrow_mut().pop();
- // Step 7 exception handling
+ // Step 8 exception handling
if let Err(error) = result {
- // Step 7.1
+ // Step 8.exception.1
element.set_custom_element_state(CustomElementState::Failed);
- // Step 7.2
+ // Step 8.exception.2 isn't needed since step 3 hasn't happened yet
+
+ // Step 8.exception.3
element.clear_reaction_queue();
- // Step 7.3
+ // Step 8.exception.4
let global = GlobalScope::current().expect("No current global");
let cx = global.get_cx();
unsafe {
throw_dom_exception(cx, &global, error);
report_pending_exception(*cx, true);
}
+
return;
}
- // Step 8
+ // TODO Step 9: "If element is a form-associated custom element..."
+
+ // Step 10
+
element.set_custom_element_state(CustomElementState::Custom);
- // Step 9
+ // Step 3
element.set_custom_element_definition(definition);
}
/// <https://html.spec.whatwg.org/multipage/#concept-upgrade-an-element>
-/// Steps 7.1-7.2
+/// Steps 8.1-8.3
#[allow(unsafe_code)]
fn run_upgrade_constructor(
constructor: &Rc<CustomElementConstructor>,
@@ -654,10 +663,12 @@ fn run_upgrade_constructor(
}
rooted!(in(*cx) let mut construct_result = ptr::null_mut::<JSObject>());
{
+ // Step 8.1 TODO when shadow DOM exists
+
// Go into the constructor's compartment
let _ac = JSAutoRealm::new(*cx, constructor.callback());
let args = HandleValueArray::new();
- // Step 7.1
+ // Step 8.2
if unsafe {
!Construct1(
*cx,
@@ -668,7 +679,7 @@ fn run_upgrade_constructor(
} {
return Err(Error::JSFailed);
}
- // Step 7.2
+ // Step 8.3
let mut same = false;
rooted!(in(*cx) let construct_result_val = ObjectValue(construct_result.get()));
if unsafe {