mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-13 03:29:49 +00:00
LibWeb: Implement Node.lookupNamespaceURI()
This method takes a prefix and returns the namespace URI associated with it on the given node, or null if no namespace is found.
This commit is contained in:
parent
d106b6eae2
commit
27d429a85f
Notes:
sideshowbarker
2024-07-18 23:46:13 +09:00
Author: https://github.com/tcl3
Commit: 27d429a85f
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/693
5 changed files with 166 additions and 1 deletions
43
Tests/LibWeb/Text/input/DOM/Node-lookupNamespaceURI.html
Normal file
43
Tests/LibWeb/Text/input/DOM/Node-lookupNamespaceURI.html
Normal file
|
@ -0,0 +1,43 @@
|
|||
<!DOCTYPE html>
|
||||
<script src="../include.js"></script>
|
||||
<script>
|
||||
function testLookupNamespaceURI(node, prefix, name) {
|
||||
let prefixName = prefix;
|
||||
if (prefixName !== null)
|
||||
prefixName = `"${prefix}"`;
|
||||
|
||||
println(`${name}.lookupNamespaceURI(${prefixName}): ${node.lookupNamespaceURI(prefix)}`);
|
||||
}
|
||||
|
||||
test(() => {
|
||||
const documentFragment = document.createDocumentFragment();
|
||||
testLookupNamespaceURI(documentFragment, null, "documentFragment");
|
||||
testLookupNamespaceURI(documentFragment, "", "documentFragment");
|
||||
testLookupNamespaceURI(documentFragment, "foo", "documentFragment");
|
||||
testLookupNamespaceURI(documentFragment, "xml", "documentFragment");
|
||||
testLookupNamespaceURI(documentFragment, "xmlns", "documentFragment");
|
||||
|
||||
const docType = document.doctype;
|
||||
testLookupNamespaceURI(docType, null, "docType");
|
||||
testLookupNamespaceURI(docType, "", "docType");
|
||||
testLookupNamespaceURI(docType, "foo", "docType");
|
||||
testLookupNamespaceURI(docType, "xml", "docType");
|
||||
testLookupNamespaceURI(docType, "xmlns", "docType");
|
||||
|
||||
const element = document.createElementNS("namespace", "prefix:element");
|
||||
element.setAttribute("bar", "value");
|
||||
testLookupNamespaceURI(element, null, "element");
|
||||
testLookupNamespaceURI(element, "", "element");
|
||||
testLookupNamespaceURI(element, "foo", "element");
|
||||
testLookupNamespaceURI(element, "xml", "element");
|
||||
testLookupNamespaceURI(element, "xmlns", "element");
|
||||
|
||||
const XMLNS_NS = "http://www.w3.org/2000/xmlns/";
|
||||
element.setAttributeNS(XMLNS_NS, 'xmlns:bar', 'exampleNamespaceURI');
|
||||
println("After setting element attribute xmlns:bar='exampleNamespaceURI'");
|
||||
testLookupNamespaceURI(element, null, "element");
|
||||
testLookupNamespaceURI(element, "", "element");
|
||||
testLookupNamespaceURI(element, "foo", "element");
|
||||
testLookupNamespaceURI(element, "bar", "element");
|
||||
});
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue