-
Notifications
You must be signed in to change notification settings - Fork 122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support to render XML namespace #47
Conversation
test/test-dom.js
Outdated
|
||
ist(derivedDOM.innerHTML, declaredDOM.innerHTML) | ||
console.log(derivedDOM.innerHTML); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a leftover debugging statement.
src/to_dom.js
Outdated
if (typeof structure == "string") | ||
return {dom: doc.createTextNode(structure)} | ||
if (structure.nodeType != null) | ||
return {dom: structure} | ||
let dom = doc.createElement(structure[0]), contentDOM = null | ||
let contentDOM = null | ||
let [xmlns, tag] = structure[0].split(' ', 2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you do something involving structure[0].indexOf(" ")
to check for the presence of a space, to avoid allocating another array for every element?
src/to_dom.js
Outdated
@@ -4,7 +4,8 @@ | |||
// itself, or an array. | |||
// | |||
// An array describes a DOM element. The first value in the array | |||
// should be a string—the name of the DOM element. If the second | |||
// should be a string—the name of the DOM element. It also can be | |||
// space-separated the XML namespace and the name. If the second |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"the name of the DOM element, optionally prefixed by a namespace URL and a space." is probably a better phrasing.
@marijnh Thank you for your reviewing! If you'd like, I'll squash them to one. Thanks. |
Thank you. Merged as 66df625, released as 1.9.0 |
This pull request will add support to render XML namespace with
toDOM
function.Usage
This pull request will expand the first item of returned value of
toDOM
function.It will receive space-separated string. The first one is XML namespace, and the second is element name.
We can also use XML namespace for attributes in the same way.
related issue