mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
Ensure id attributes on elements only affect elements present in a document.
This commit is contained in:
parent
edd7e32fdb
commit
70e8a5e90f
2 changed files with 11 additions and 2 deletions
|
@ -223,7 +223,7 @@ impl Element {
|
||||||
"style" => {
|
"style" => {
|
||||||
self.style_attribute = Some(style::parse_style_attribute(value))
|
self.style_attribute = Some(style::parse_style_attribute(value))
|
||||||
}
|
}
|
||||||
"id" => {
|
"id" if abstract_self.is_in_doc() => {
|
||||||
// XXX: this dual declaration are workaround to avoid the compile error:
|
// XXX: this dual declaration are workaround to avoid the compile error:
|
||||||
// "borrowed value does not live long enough"
|
// "borrowed value does not live long enough"
|
||||||
let doc = self.node.owner_doc();
|
let doc = self.node.owner_doc();
|
||||||
|
@ -287,7 +287,7 @@ impl Element {
|
||||||
"style" => {
|
"style" => {
|
||||||
self.style_attribute = None
|
self.style_attribute = None
|
||||||
}
|
}
|
||||||
"id" => {
|
"id" if abstract_self.is_in_doc() => {
|
||||||
// XXX: this dual declaration are workaround to avoid the compile error:
|
// XXX: this dual declaration are workaround to avoid the compile error:
|
||||||
// "borrowed value does not live long enough"
|
// "borrowed value does not live long enough"
|
||||||
let doc = self.node.owner_doc();
|
let doc = self.node.owner_doc();
|
||||||
|
|
|
@ -66,6 +66,15 @@
|
||||||
is(e2, null, "test3-2, the method should return null when the passed id is none in document.");
|
is(e2, null, "test3-2, the method should return null when the passed id is none in document.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
// Ensure that the id attribute only affects elements present in a document
|
||||||
|
let e = document.createElement('div');
|
||||||
|
e.id = "should-not-exist";
|
||||||
|
is(document.getElementById("should-not-exist"), null);
|
||||||
|
document.body.appendChild(e);
|
||||||
|
is(document.getElementById("should-not-exist"), e);
|
||||||
|
}
|
||||||
|
|
||||||
// TODO:
|
// TODO:
|
||||||
// test4: "in tree order, within the context object's tree"
|
// test4: "in tree order, within the context object's tree"
|
||||||
// http://dom.spec.whatwg.org/#dom-document-getelementbyid.
|
// http://dom.spec.whatwg.org/#dom-document-getelementbyid.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue