javascript - How to determine at runtime whether a tag is valid inside a DOM element? -
i working on js plugin (just show me colors) walks dom tree (which not under control) , replaces textnodes
span
.
there contexts when result in invalid markup, inside svg:text
node. however, code doesn't throw errors in chrome/ff:
var text = document.createelementns("http://www.w3.org/2000/svg", "svg:text"); text.appendchild(document.craeteelement("span"));
even though invalid markup.
similarly, putting div
inside p
allowed works (tm).
however, putting span
inside script
tag allowed not work.
is there way can determine @ runtime whether markup generating valid or work or not?
the simplest solution might keep list of elements can validly contain span.
here's list : http://w3-video.com/web_technologies/html5/span/html5_span_tag_nested.php
Comments
Post a Comment