javascript - Browser custom namespaced element processors -
in browser environment, creating svg element way
svg = document.createelement('svg');
appending body , populating svg elements not work, because
svg.namespaceuri === 'http://www.w3.org/1999/xhtml'
doing way
svg = document.createelementns('http://www.w3.org/2000/svg','svg')
work.
that's reasonable element should processed in svg way , not in html way
similarly, creating
select = document.createelementns('xxxx','select')
, appending body, element won't show known select
dropdown, because browser informed not http://www.w3.org/1999/xhtml:select
element xxxx:select
instead.
seemes node processing dispatched different processors depending on ns(when recognized) of node itself.
possible define custom namespaceuri document in order let nodes specific nsuri processed in custom fashion, through function ?
note, not expected result ? answer attempts demonstrate 1 method of using processinginstruction
// create `processinginstruction` var p = document.createprocessinginstruction("js", "{\"color\":\"blue\"}"); var div = document.getelementbyid("process"); document.body.insertbefore(p, div); // use `processinginstruction` div.style.color = json.parse(div.previoussibling.nodevalue).color;
<!doctype html> <html> <body> <div id="process">process</div> </body> </html>
Comments
Post a Comment