mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
Fix crash when id attribute is set via SetAttributeNode
This commit is contained in:
parent
154186f420
commit
2ccf729aa3
3 changed files with 30 additions and 0 deletions
|
@ -1543,6 +1543,10 @@ impl ElementMethods for Element {
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-element-setattributenode
|
// https://dom.spec.whatwg.org/#dom-element-setattributenode
|
||||||
fn SetAttributeNode(&self, attr: &Attr) -> Fallible<Option<Root<Attr>>> {
|
fn SetAttributeNode(&self, attr: &Attr) -> Fallible<Option<Root<Attr>>> {
|
||||||
|
// Workaround for https://github.com/servo/servo/issues/17366
|
||||||
|
// This ensures that if this is an "id" attr, its value is an Atom
|
||||||
|
attr.swap_value(&mut self.parse_plain_attribute(attr.local_name(), attr.Value()));
|
||||||
|
|
||||||
// Step 1.
|
// Step 1.
|
||||||
if let Some(owner) = attr.GetOwnerElement() {
|
if let Some(owner) = attr.GetOwnerElement() {
|
||||||
if &*owner != self {
|
if &*owner != self {
|
||||||
|
|
|
@ -13024,6 +13024,12 @@
|
||||||
{}
|
{}
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
|
"mozilla/element_setAttributeNode.html": [
|
||||||
|
[
|
||||||
|
"/_mozilla/mozilla/element_setAttributeNode.html",
|
||||||
|
{}
|
||||||
|
]
|
||||||
|
],
|
||||||
"mozilla/empty_clientrect.html": [
|
"mozilla/empty_clientrect.html": [
|
||||||
[
|
[
|
||||||
"/_mozilla/mozilla/empty_clientrect.html",
|
"/_mozilla/mozilla/empty_clientrect.html",
|
||||||
|
@ -25731,6 +25737,10 @@
|
||||||
"9ddf84332ca6efa6390315f20d59be2964a69dc7",
|
"9ddf84332ca6efa6390315f20d59be2964a69dc7",
|
||||||
"testharness"
|
"testharness"
|
||||||
],
|
],
|
||||||
|
"mozilla/element_setAttributeNode.html": [
|
||||||
|
"4159931c8fc73a2305fa3d3bfe988132f38b4975",
|
||||||
|
"testharness"
|
||||||
|
],
|
||||||
"mozilla/empty_clientrect.html": [
|
"mozilla/empty_clientrect.html": [
|
||||||
"0860a059be4885f2b48de1aa7d87b8d0a7058195",
|
"0860a059be4885f2b48de1aa7d87b8d0a7058195",
|
||||||
"testharness"
|
"testharness"
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
<!doctype html>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>Element setAttributeNode</title>
|
||||||
|
<script src="/resources/testharness.js"></script>
|
||||||
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
|
<div id="test"></div>
|
||||||
|
<script>
|
||||||
|
test(function() {
|
||||||
|
var element = document.getElementById("test");
|
||||||
|
var attr = document.createAttribute("id");
|
||||||
|
attr.value = "foo";
|
||||||
|
element.setAttributeNode(attr);
|
||||||
|
var id = element.getAttribute("id");
|
||||||
|
assert_equals(id, "foo", "getAttribute should have value 'foo'");
|
||||||
|
});
|
||||||
|
</script>
|
Loading…
Add table
Add a link
Reference in a new issue