I''ve been playing around with the release candidate, in particular with the new features that $$ has, and I''ve noticed some inconsistencies with how it behaves in IE 6 after an Element.update. Basically, it seems like some of the attribute selectors (= and ^=) aren''t selecting tags that are in a div that has been updated. Heres a SSCCE: dd.html: <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <script type="text/javascript" src="http://prototypejs.org/ assets/2007/3/12/prototype.js"></script> <title>$$ Update Test</title> </head> <body> <div id="content"> <a class="appLink" href="dd.html">$$ Test</a> </div> <script type="text/javascript"> function rewrite() { // don''t work //var css = ''div a[href="dd.html"]''; //var css = ''div a[href^="dd"]''; // work var css = ''div a[href]''; //var css = ''div a[href!="ff.html"]''; //var css = ''div a[href$="html"]''; //var css = ''div a[href*="."]''; //var css = ''div a.appLink''; $$(css).each(function(a) { a.setStyle({color: ''pink''}); a.onclick = function() { $(''content'').update(''<a class="appLink" href="dd.html">$$ Test</a>''); rewrite(); return false; }; }); } rewrite(); </script> </body> </html> --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
This appears to be an issue with IE''s shoddy implementation of getAttribute. (http://tobielangel.com/2007/1/11/attribute-nightmare-in- ie) If you do... $$(''a.appLink'')[0].getAttribute(''href''); ... you''ll get the resolved URL ("file://foo/bar/whatever/dd.html" if you''re running on a drive) instead of the literal value of the href attribute ("dd.html"). Prototype''s own Element#readAttribute attempts to fix this (and is used internally by $$), but it appears to fail after a call to Element#update. I''ll file a bug on this and make Tobie do all the work. I doubt a fix for this will get into 1.5.1, but I''m sure we can address it for 1.5.2. Meanwhile, you can use the "$=" operator as a workaround. Cheers, Andrew On Mar 26, 11:53 am, "djthomp" <djth...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I''ve been playing around with the release candidate, in particular > with the new features that $$ has, and I''ve noticed some > inconsistencies with how it behaves in IE 6 after an Element.update. > Basically, it seems like some of the attribute selectors (= and ^=) > aren''t selecting tags that are in a div that has been updated. > > Heres a SSCCE: > > dd.html: > <html> > <head> > <meta http-equiv="Content-Type" content="text/html; > charset=UTF-8" /> > <script type="text/javascript" src="http://prototypejs.org/ > assets/2007/3/12/prototype.js"></script> > <title>$$ Update Test</title> > </head> > <body> > <div id="content"> > <a class="appLink" href="dd.html">$$ Test</a> > </div> > > <script type="text/javascript"> > function rewrite() { > > // don''t work > //var css = ''div a[href="dd.html"]''; > //var css = ''div a[href^="dd"]''; > > // work > var css = ''div a[href]''; > //var css = ''div a[href!="ff.html"]''; > //var css = ''div a[href$="html"]''; > //var css = ''div a[href*="."]''; > //var css = ''div a.appLink''; > > $$(css).each(function(a) { > a.setStyle({color: ''pink''}); > > a.onclick = function() { > $(''content'').update(''<a class="appLink" > href="dd.html">$$ Test</a>''); > rewrite(); > > return false; > }; > }); > } > > rewrite(); > </script> > </body> > </html>--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Tobie and I looked at this, wrote a few reduced test cases, and reluctantly concluded that we''re fucked here. If you tell IE to give you the generated source of your test page (i.e. document.body.innerHTML), it''ll return its own "normalized" version of your markup. One of the things it does when normalizing is to expand all relative URLs to their fully-resolved equivalents. This ordinarily isn''t a problem, since you can get at the initial value with "someElement.getAttribute(''href'' 2);". Tobie''s "attribute nightmare" blog post linked to in my previous message goes into this in detail. When you *set* innerHTML, though, IE normalizes your markup string *before* it appends that markup to the DOM. So in this case, using "someElement.getAttribute(''href'', 2)" will return the normalized & resolved URL, since the DOM has never seen whatever you originally set that HREF to. This is just one more example of how the Document Object Model is attached to IE6 with duct tape. One workaround is to be aware of this gotcha and to craft your CSS selectors accordingly (i.e., using "$=" instead of "=" like I advised in my last message). Another is to use the DOM element creation methods instead of innerHTML wherever possible -- but that doesn''t help you at all with Ajax.Updater or Element#update. We''re planning to add DOM node support to Element#update (so that it can take either a string or an existing DOM node) in the 1.5.2 release of Prototype. That should make things a bit easier. Cheers, Andrew --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Ahh, well that makes sense in a sick twisted way. When I noticed the problem it appeared that IE was breaking the beginning of the string such that start-of-string match and equality match were broken, but that just seemed kinda strange. For my actual usage where I noticed the problem, I was looking for urls with a parameter string, and for that [href*="foo.jsp?"] seems to work just as well as [href^="foo.jsp?"]. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---