aboutsummaryrefslogtreecommitdiffstats
path: root/components/script
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2017-04-20 01:01:05 -0500
committerGitHub <noreply@github.com>2017-04-20 01:01:05 -0500
commit2d732d829b3fc93938898118ee55ef985ebfc657 (patch)
tree23efb360891553acbe5c72e1cfb521c6b169e39d /components/script
parent7919e591a46274c0d7f3a7c7c99d2643d55d60f1 (diff)
parentbef86cbf369be4b23d4ec8be3a4cd3df452e9c2f (diff)
downloadservo-2d732d829b3fc93938898118ee55ef985ebfc657.tar.gz
servo-2d732d829b3fc93938898118ee55ef985ebfc657.zip
Auto merge of #16472 - cu1t:#14095-fix-xml-doc-namespaces, r=nox
Fix namespaces of elements created in XML documents Correctly implement following step of [Dom Document Spec](https://dom.spec.whatwg.org/#dom-document-createelement): > Let namespace be the HTML namespace, if the context object is an HTML document or context object’s content type is "application/xhtml+xml", and null otherwise. Note, this will make following test in `tests/wpt/web-platform-tests/dom/nodes/Document-constructor.html` to fail, so related .ini file added to mark it as such: ``` test(function() { var doc = new Document(); var a = doc.createElement("a"); // In UTF-8: 0xC3 0xA4 a.href = "http://example.org/?\u00E4"; assert_equals(a.href, "http://example.org/?%C3%A4"); }, "new Document(): URL parsing") ``` I'm not very familiar with specs, but from quick look at it, I'm doubtfull that it is valid in the first place. This is an "application/xml" document, so I don't see why it should encode a.href. Firefox also fails that. --- <!-- 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 #14095 (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [X] These changes do not require tests because because there are already tests which were being ignored <!-- 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. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/16472) <!-- Reviewable:end -->
Diffstat (limited to 'components/script')
-rw-r--r--components/script/dom/document.rs9
1 files changed, 8 insertions, 1 deletions
diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs
index 940baaca36f..425336fd669 100644
--- a/components/script/dom/document.rs
+++ b/components/script/dom/document.rs
@@ -2772,7 +2772,14 @@ impl DocumentMethods for Document {
if self.is_html_document {
local_name.make_ascii_lowercase();
}
- let name = QualName::new(ns!(html), LocalName::from(local_name));
+
+ let ns = if self.is_html_document || self.content_type == "application/xhtml+xml" {
+ ns!(html)
+ } else {
+ ns!()
+ };
+
+ let name = QualName::new(ns, LocalName::from(local_name));
Ok(Element::create(name, None, self, ElementCreator::ScriptCreated))
}