Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

jqLite should create elements in same way as jQuery #369

Closed
vojtajina opened this issue Jun 6, 2011 · 3 comments · Fixed by #435
Closed

jqLite should create elements in same way as jQuery #369

vojtajina opened this issue Jun 6, 2011 · 3 comments · Fixed by #435
Milestone

Comments

@vojtajina
Copy link
Contributor

Gist to reproduce issue: https://gist.github.com/1010228

First script - create script element using jqLite - load source for failed
Second script - create script element using raw document.createElement() - success

When loading jQuery, it works fine (jgLite uses jQuery then)...

For More more info see: #344

On my Ubuntu machine the issue is seen only on FF4, works fine on Chrome, FF3.

Observing the issue:

  • open firebug's HTML and check both scripts, first content is "Failed to load source...", second works fine
  • open firebug's NET there is request for "....?param2", but no request for "...?param1"
@IgorMinar
Copy link
Contributor

We will likely never do everything that jquery does to create elements, but the <script> case is likely simple enough that it should be supported.

jQuery does a lot of magic to create elements and nodes because they have to. We are not interested in going into that business, so only the most common elements should be supported by us.

@ghost ghost assigned Codier Jun 23, 2011
@Codier Codier closed this as completed Jun 24, 2011
@IgorMinar IgorMinar reopened this Jun 24, 2011
@IgorMinar
Copy link
Contributor

We researched this and jquery does some crazy shit to get this to work. The main problem is that when you use innerHTML to create DOM elements from a string, browsers sometimes don't create these elements in the same way as if you created them via document.createElement and then appended the element to the document.

This affects the script tags as well and results in the scripts not executing when a dom chunk with script element is appended to the document.

In order for us to get this to work, we'd have to parse and append html before any script tag, parse out the script tag, execute it, and parse and append any non-script html afterwards. If we wanted to support deffered and asyc scripts, things would be even more complicated.

This is too much craziness for jqlite, so we are not going to do it. Instead we are going to document that if you want have script elements in ng:include or ng:view templates, you should use jquery.

@vojtajina vojtajina reopened this Jun 27, 2011
@vojtajina
Copy link
Contributor Author

I agree on that - we don't want to do all the things jQuery does to get this working.

But then, we have to revert $browser.xhr to use rawDocument.createElement('script') instead of jqLite to get JSONP working...

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

Successfully merging a pull request may close this issue.

3 participants