Skip to content
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

Uize.Node.injectHtml, script tags, and Safari #20

Open
timcarter opened this issue Mar 28, 2012 · 3 comments
Open

Uize.Node.injectHtml, script tags, and Safari #20

timcarter opened this issue Mar 28, 2012 · 3 comments

Comments

@timcarter
Copy link
Contributor

It looks like there's a bug in Uize.Node.injectHtml in Safari. When trying to inject some markup, only top-level script tags are evaluated. Any nested tags are ignored. This has caused some problems while dynamically loading content (such as a dialog) into a page. I've thrown together a quick demonstration page at: http://timcarter.github.com/bugs/injectscript.html.

On that page, Firefox, Chrome, and IE throw two alerts while Safari throws only one. The first alert is contained in the top-level script tag while the second is nested one level under a

tag.

@UIZE
Copy link
Owner

UIZE commented Mar 28, 2012

What's your recommended fix?

@timcarter
Copy link
Contributor Author

I've isolated the problem to the _fixCrippledScripts function in Uize.Node.injectHtml. The else-if clause in that function uses Uize.forEach, which in turn only executes the _iterationHandler if the _source parameter is an array, object, or number. In all browsers except Safari, the child node list passed as the _source parameter is an object; in Safari it's a function.

My suggestion is to change the _isObject check in Uize.forEach to use the new canExtend method, similar to how you modified Uize.copyInto last week.

@UIZE
Copy link
Owner

UIZE commented Apr 2, 2012

Tim, thanks for looking into that. I will make the change and commit a fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants