I believe this could be shortened like so: Element.addMethods({ isOrphaned: function(element){ if (element.id) { return !!element.ownerDocument.getElementById(element.id); } return !!element.up('body'); } });
Do you necessarily have to do .up('body') (instead of just .up())? -- kangax On Jun 30, 12:47 pm, mr_justin <[EMAIL PROTECTED]> wrote: > Was playing around with this some more, and realized I my best option > is to just attempt to fetch the element in question. Makes for a > pretty quick operation if the ID is present, otherwise the alternate > method would be crawling back up the DOM from the element to find the > body element (assuming the body has not been removed). > > This seems to do the trick:http://pastie.org/224848 > > If you know of a more efficient way please say so :) > > -justin --~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---