dom: createAttribute() should not produce a prefix
https://dom.spec.whatwg.org/#dom-document-createattribute
document.createAttribute("foo:bar") created an Attr object with
prefix="foo" localName="bar" namespaceURI=null. It should be
one with prefix=null localName="foo:bar" namespaceURI=null.
The new behavior matches to Firefox and Edge.
Bug: 961328
Change-Id: If18c9c427dba3eaa38b3b69c32544ea8b91c2f94
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1611059
Reviewed-by: Yoshifumi Inoue <yosin@chromium.org>
Commit-Queue: Kent Tamura <tkent@chromium.org>
Cr-Commit-Position: refs/heads/master@{#659358}
diff --git a/dom/nodes/Document-createAttribute.html b/dom/nodes/Document-createAttribute.html
index b5afa6e..b494257 100644
--- a/dom/nodes/Document-createAttribute.html
+++ b/dom/nodes/Document-createAttribute.html
@@ -17,13 +17,25 @@
assert_throws("INVALID_CHARACTER_ERR", function() {
document.createAttribute(name, "test");
});
- }, "HTML document.createAttribute(" + format_value(name) + ")");
+ }, "HTML document.createAttribute(" + format_value(name) + ") should throw");
test(function() {
assert_throws("INVALID_CHARACTER_ERR", function() {
xml_document.createAttribute(name, "test");
});
- }, "XML document.createAttribute(" + format_value(name) + ")");
+ }, "XML document.createAttribute(" + format_value(name) + ") should throw");
+});
+
+valid_names.forEach(name => {
+ test(() => {
+ let attr = document.createAttribute(name);
+ attr_is(attr, "", name.toLowerCase(), null, null, name.toLowerCase());
+ }, `HTML document.createAttribute(${format_value(name)})`);
+
+ test(() => {
+ let attr = xml_document.createAttribute(name);
+ attr_is(attr, "", name, null, null, name);
+ }, `XML document.createAttribute(${format_value(name)})`);
});
var tests = ["title", "TITLE", null, undefined];
diff --git a/dom/nodes/productions.js b/dom/nodes/productions.js
index 2b99590..218797f 100644
--- a/dom/nodes/productions.js
+++ b/dom/nodes/productions.js
@@ -1,3 +1,3 @@
var invalid_names = ["", "invalid^Name", "\\", "'", '"', "0", "0:a"] // XXX
-var valid_names = ["x", ":", "a:0"]
+var valid_names = ["x", "X", ":", "a:0"]
var invalid_qnames = [":a", "b:", "x:y:z"] // XXX