Ran across a problem while piping down JSON from a Rails server... apparently Element.update will accept undefined for the html parameter... but not null? As such: Element.update(''something'', undefined) => clears out the element Element.update(''something'', null) => blows out with an error I''m not sure if nobody''s noticed this, or everyone''s worked around it, or if there''s some bigger, logical reason why undefined is okay but null isn''t (if so, please let me know!)... but I just extend Element and Element.Methods in my own extension library to counteract this issue. Anyway, if this makes sense, I threw together a quick patch... thought I''d contribute a little something back: diff -ru prototype/src/dom.js prototype_orig/src/dom.js --- prototype/src/dom.js 2007-06-12 09:47:08.875000000 -0700 +++ prototype_orig/src/dom.js 2007-06-12 09:29:39.839007000 -0700 @@ -84,7 +84,7 @@ }, update: function(element, html) { - html = (typeof html == ''undefined'' || html == null) ? '''' : html.toString(); + html = typeof html == ''undefined'' ? '''' : html.toString(); $(element).innerHTML = html.stripScripts(); html.evalScripts.bind(html).defer(); return element; --~--~---------~--~----~------------~-------~--~----~ 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
2007-Jun-12 18:32 UTC
Re: Element.update supports html==undefined but not html==null?
Element.update will get some love for v. 1.6 This will be dealt with. On Jun 12, 12:58 pm, jriesen <jrie...-IsOEJWsDUnlBDgjK7y7TUQ@public.gmane.org> wrote:> Ran across a problem while piping down JSON from a Rails server... > apparently Element.update will accept undefined for the html > parameter... but not null? As such: > > Element.update(''something'', undefined) => clears out the element > Element.update(''something'', null) => blows out with an error > > I''m not sure if nobody''s noticed this, or everyone''s worked around it, > or if there''s some bigger, logical reason why undefined is okay but > null isn''t (if so, please let me know!)... but I just extend Element > and Element.Methods in my own extension library to counteract this > issue. Anyway, if this makes sense, I threw together a quick patch... > thought I''d contribute a little something back: > > diff -ru prototype/src/dom.js prototype_orig/src/dom.js > --- prototype/src/dom.js 2007-06-12 09:47:08.875000000 -0700 > +++ prototype_orig/src/dom.js 2007-06-12 09:29:39.839007000 -0700 > @@ -84,7 +84,7 @@ > }, > > update: function(element, html) { > - html = (typeof html == ''undefined'' || html == null) ? '''' : > html.toString(); > + html = typeof html == ''undefined'' ? '''' : html.toString(); > $(element).innerHTML = html.stripScripts(); > html.evalScripts.bind(html).defer(); > return element;--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---