mirror of
https://github.com/servo/servo.git
synced 2025-08-02 20:20:14 +01:00
Implement Node.baseURI
This commit is contained in:
parent
0fb6604cb3
commit
dbbab3b113
4 changed files with 38 additions and 6 deletions
|
@ -993,7 +993,7 @@ impl<'a> NodeHelpers for &'a Node {
|
|||
fn summarize(self) -> NodeInfo {
|
||||
NodeInfo {
|
||||
uniqueId: self.get_unique_id(),
|
||||
baseURI: self.GetBaseURI().unwrap_or("".to_owned()),
|
||||
baseURI: self.BaseURI(),
|
||||
parent: self.GetParentNode().map(|node| node.r().get_unique_id()).unwrap_or("".to_owned()),
|
||||
nodeType: self.NodeType(),
|
||||
namespaceURI: "".to_owned(), //FIXME
|
||||
|
@ -1956,9 +1956,8 @@ impl<'a> NodeMethods for &'a Node {
|
|||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-node-baseuri
|
||||
fn GetBaseURI(self) -> Option<DOMString> {
|
||||
// FIXME (#1824) implement.
|
||||
None
|
||||
fn BaseURI(self) -> DOMString {
|
||||
self.owner_doc().URL()
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-node-ownerdocument
|
||||
|
|
|
@ -26,7 +26,7 @@ interface Node : EventTarget {
|
|||
readonly attribute DOMString nodeName;
|
||||
|
||||
[Pure]
|
||||
readonly attribute DOMString? baseURI;
|
||||
readonly attribute DOMString baseURI;
|
||||
|
||||
[Pure]
|
||||
readonly attribute Document? ownerDocument;
|
||||
|
|
|
@ -13117,6 +13117,10 @@
|
|||
"path": "dom/nodes/Node-appendChild.html",
|
||||
"url": "/dom/nodes/Node-appendChild.html"
|
||||
},
|
||||
{
|
||||
"path": "dom/nodes/Node-baseURI.html",
|
||||
"url": "/dom/nodes/Node-baseURI.html"
|
||||
},
|
||||
{
|
||||
"path": "dom/nodes/Node-childNodes.html",
|
||||
"url": "/dom/nodes/Node-childNodes.html"
|
||||
|
|
29
tests/wpt/web-platform-tests/dom/nodes/Node-baseURI.html
Normal file
29
tests/wpt/web-platform-tests/dom/nodes/Node-baseURI.html
Normal file
|
@ -0,0 +1,29 @@
|
|||
<!DOCTYPE html>
|
||||
<title>Node.baseURI</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
test(function() {
|
||||
var element =document.createElement("div");
|
||||
document.getElementById("log").appendChild(element);
|
||||
assert_equals(element.baseURI, document.URL);
|
||||
}, "For elements belonging to document, baseURI should be document url")
|
||||
test(function() {
|
||||
var element =document.createElement("div");
|
||||
assert_equals(element.baseURI, document.URL);
|
||||
}, "For elements unassigned to document, baseURI should be document url")
|
||||
test(function() {
|
||||
var fragment = document.createDocumentFragment();
|
||||
var element =document.createElement("div");
|
||||
fragment.appendChild(element);
|
||||
assert_equals(element.baseURI, document.URL)
|
||||
}, "For elements belonging to document fragments, baseURI should be document url")
|
||||
test(function() {
|
||||
var fragment = document.createDocumentFragment();
|
||||
var element =document.createElement("div");
|
||||
fragment.appendChild(element);
|
||||
document.getElementById("log").appendChild(fragment);
|
||||
assert_equals(element.baseURI, document.URL)
|
||||
}, "After inserting fragment into document, element baseURI should be document url")
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue