Closed ahopkins closed 1 year ago
You need to use _script
for inline scripts. This is mentioned in README.
Autodetecting this, doing the right thing if .script
or .style
are used would be nice but also difficult to do. Adding a logic for checking this when content is being added to an element would degrade performance. Adding script
and style
methods would not affect performance, but then behave unexpectedly if not immediately followed by function call. In particular this construct would not add any script tag:
with doc.script:
doc("javascript code")
Perhaps if script and style were properties that either provided a proxy object or modified the main Builder object to use different escaping for that tag's content... A bit convoluted no matter which way it is done.
Ahh, makes sense. Without looking at anything, the proxy approach sounds right. Using _script
is unfortunately not intuitive when it otherwise does seem to work without the underscore.
Current work around:
When adding script, we shouldn't escape entities as it messes with the rendered Javascript.