> Global eval is actually one of the most popular addition requests > (after people realize that `evalScripts` does not evaluate within > global scope :))
Yeah, big time; I was just pointing out that the change suggested won't provide it (except in Gecko browsers). I'd done some previous work on this. I just went and dug it out and cleaned it up. This version works on FF3, IE6, Safari3win, and Opera9: http://pastie.org/310725 It looks like Yaffle hasn't opened a ticket for this, so I did: http://prototype.lighthouseapp.com/projects/8886-prototype/tickets/433 > It's funny that after playing with comments stripping (as per author > suggestion) I realized that out `extractScripts` is not as robust as > it could be: And Yaffle's suggested addition -- if it does what I think it does, ignoring end tags if they're within a comment (I'm relatively worthless at regex) -- looks like it helps some. Not in the situation you're talking about, but isn't that unrealistic? This: function(){ return "</script>" } ...doesn't work in most browsers AFAIK. (Checked checked FF3, IE6, Safari3win, Opera9.) I think one has to be careful to do things like this: function(){ return "</scr" + "ipt>" } ...to avoid the HTML parser ending the script early. -- T.J. Crowder tj / crowder software / com On Nov 9, 5:33 am, kangax <[EMAIL PROTECTED]> wrote: > On Nov 8, 6:14 am, "T.J. Crowder" <[EMAIL PROTECTED]> wrote: > > > Yaffle, > > > (Just FWIW, I sense you're not a native English speaker, so I'll just > > mention that posting a message called "Prototype.js mistakes" will > > tend to be unnecessarily offensive to the folks you're trying to talk > > to.) > > > On the script thing, by all means open a ticket on Lighthouse (details > > here[1]) and submit a patch; thank you in advance. > > > On the eval thing: eval is a global function, not a property of the > > window object.[2] Some implementations (like Firefox and Opera) let > > you use window.eval and interpret the script in the context of the > > window object, which is great, but it's non-standard behavior not > > implemented by other browsers (IE and Safari, for instance). > > Global eval is actually one of the most popular addition requests > (after people realize that `evalScripts` does not evaluate within > global scope :)) > > It's funny that after playing with comments stripping (as per author > suggestion) I realized that out `extractScripts` is not as robust as > it could be: > > var s = '<script>(function(){ return "</script>" })();</script>'; > s.extractScripts(); // '(function(){ return "' > > and so `evalScripts` obviously fails when given a cut-off function > expression : ) > > > > > [1]http://www.prototypejs.org/contribute > > [2]http://www.ecma-international.org/publications/standards/Ecma-262.htm > > -- > > T.J. Crowder > > tj / crowder software / com > > [...] > > -- > kangax --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Prototype: Core" 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/prototype-core?hl=en -~----------~----~----~----~------~----~------~--~---
