Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Add support for raw HTML nodes. #11
In XML, CDATA nodes can be used to include portions of unescaped text. HTML does not have any facility for this because it is typically not required.
However, in the case of SimpleDOM (and specifically Ember’s FastBoot), the DOM tree is just an intermediate representation of the final serialized HTML output. In some cases, users may want to put snippets of unescaped HTML into that DOM tree for delivery to the user.
One option is to parse the unescaped HTML provided by the user and turn that into DOM nodes in the intermediate DOM tree. However, this incurs a performance cost for little gain, as we parse the provided HTML, store it as a tree of nodes, then reserialize that tree immediately afterwards when the entire document is being serialized.
By providing a CDATA mechanism, we can allow consumers of SimpleDOM to “stash” unparsed HTML in the tree, which is then re-emitted without parsing when that tree is serialized.
I've reconsidered whether trying to use the CDATA API is a good idea. For now, let's create a custom extension that avoids the uncanny valley problem and makes the use case more explicit. This is also less likely to conflict with potential future use cases that want to legitimately use CDATA (although I doubt that day will ever come to pass).