Whoa, Ariel, you were busy yesterday!

> jQuery('<script type="text/javascript">alert("a")</script>').appendTo
> ('body')
> jQuery('<div><script type="text/javascript">alert("a")</script></
> div>').appendTo('body')

Ahhhh. domManip uses the new document fragment technique for calling
clean, but there are two other places where clean is called: init and
clone. They are using the old calling convention and don't pass in a
fragment, so they don't handle scripts correctly.

As a quick check, I changed the code in init to this:

// HANDLE: $(html) -> $(array)
if ( match[1] ) {
        var fragment = (context||document).createDocumentFragment(),
        scripts = jQuery.clean( [ match[1] ], context, fragment );
        selector = fragment.childNodes;
        jQuery.each(scripts||[], evalScript);
}

Then it does execute scripts properly, but that seems like a lot of
duplicated complex code...and it still needs to be put into clone.

I was thinking clean could execute the scripts, but then they will run
*before* the content from the same string is put into the DOM; that
could break code that expects to act on elements inserted in the same
HTML chunk.

Originally I thought it was a bug that script elements are collected
from string arguments, but looking at it some more I realized that if
the incoming args were DOM elements then they were most likely coming
from the document itself and had already been executed. Is that why
they are not executed, but are removed?

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"jQuery Development" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/jquery-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to