I was fooling around with Firefox 3 Beta 2 and noticed some code I''d written previously didn''t work. Here''s an example (abbreviated to show the relevant snippets): HTML: <div id="foo"></div> JS: document.observe(''dom:loaded'', function() { try { $(''foo'').insert(new Element(''p'').insert(''hello, world'')); } catch (e) { alert(e.message); } }); In all the current "A-grade" browsers, this works fine. In FF3b2, however, the following message is alerted: "The container of an boundary-point of a range is being set to either a node of an invalid type or a node with an ancestor of an invalid type." I''ve discovered some workarounds to this: 1. Split the two inserts into two different lines of code, that is: var p = $(''foo'').insert(new Element(''p'')); p.insert(''hello, world''); 2. Use update instead of insert, that is: $(''foo'').insert(new Element(''p'').update(''hello, world'')); 3. Insert the explicit HTML, even though I''d prefer not to; that is: $(''foo'').insert(''<p>hello, world</p>''); So, my question(s): Is this some sort of Firefox bug that needs to be reported, or have I just been using insert() incorrectly and I''ve just happened to luck out in the past? I''ve tended to favor insert() over update() when creating elements just ''cause the element wasn''t really being updated per se. If anybody''s got an explanation for what''s going on here, I''d love to hear it! :Dan Dorman --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
There was a change in the underlying DOM that will likely have a lot of people unhappy - the introduction of importNode() and adoptNode(). More info at http://developer.mozilla.org/en/docs/Updating_web_applications_for_Firefox_3 On Dec 20, 2007 9:49 AM, Dan Dorman <dan.dorman-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > I was fooling around with Firefox 3 Beta 2 and noticed some code I''d > written previously didn''t work. > > Here''s an example (abbreviated to show the relevant snippets): > > HTML: > <div id="foo"></div> > > JS: > document.observe(''dom:loaded'', function() { > try { > $(''foo'').insert(new Element(''p'').insert(''hello, world'')); > } catch (e) { > alert(e.message); > } > }); > > In all the current "A-grade" browsers, this works fine. In FF3b2, > however, the following message is alerted: > > "The container of an boundary-point of a range is being set to either > a node of an invalid type or a node with an ancestor of an invalid > type." > > I''ve discovered some workarounds to this: > > 1. Split the two inserts into two different lines of code, that is: > var p = $(''foo'').insert(new Element(''p'')); > p.insert(''hello, world''); > > 2. Use update instead of insert, that is: > $(''foo'').insert(new Element(''p'').update(''hello, world'')); > > 3. Insert the explicit HTML, even though I''d prefer not to; that is: > $(''foo'').insert(''<p>hello, world</p>''); > > So, my question(s): Is this some sort of Firefox bug that needs to be > reported, or have I just been using insert() incorrectly and I''ve just > happened to luck out in the past? I''ve tended to favor insert() over > update() when creating elements just ''cause the element wasn''t really > being updated per se. If anybody''s got an explanation for what''s going > on here, I''d love to hear it! > > :Dan Dorman > > > >-- Kurt Cagle http://www.xforms.org --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Indeed, if you run DOM unit tests, testElementUpdateWithDOMNode fails with NS_ERROR_DOM_RANGE_INVALID_NODE_TYPE_ERR error. On line 2505 (as of rev 8451) "range.selectNodeContents(element)" seems to dislike passed 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 -~----------~----~----~----~------~----~------~--~---
On Dec 20, 2007 11:49 AM, Kurt Cagle <kurt.cagle-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> There was a change in the underlying DOM that will likely have a lot of > people unhappy - the introduction of importNode() and adoptNode(). More info > at http://developer.mozilla.org/en/docs/Updating_web_applications_for_Firefox_3Thanks for the link. If I''m reading that right, nodes from external DOMs need to be imported or adopted; does this mean that a newly created element is considered to be from an external DOM? A little bit funky. On Dec 20, 2007 1:55 PM, kangax <kangax-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Indeed, if you run DOM unit tests, testElementUpdateWithDOMNode fails > with NS_ERROR_DOM_RANGE_INVALID_NODE_TYPE_ERR error. On line 2505 (as > of rev 8451) "range.selectNodeContents(element)" seems to dislike > passed element.Well, that''s good to know; thanks for the info, kangax. Does that mean this is something that''s going to be fixed in Prototype? Thanks again for the replies! :Dan Dorman --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hi, I''ve taken a more indepth look at this issue. Looks like a FF3b2 regression. Steps to reproduce in pure JS (no need for Prototype): var element, range; element = document.createElement(''div''); range = element.ownerDocument.createRange(); range.selectNodeContents(element); Which throws: NS_ERROR_DOM_RANGE_INVALID_NODE_TYPE_ERR: The container of an boundary- point of a range is being set to either a node of an invalid type or a node with an ancestor of an invalid type.([Exception... "The container of an boundary-point of a range is being set to either a node of an invalid type or a node with an ancestor of an invalid type." code: "2" nsresult: "0x805c0002 (NS_ERROR_DOM_RANGE_INVALID_NODE_TYPE_ERR)" at: range.selectNodeContents(element); Filed a bug here: https://bugzilla.mozilla.org/show_bug.cgi?id=409380 Best, Tobie --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Dec 21, 2007 5:30 AM, Tobie Langel <tobie.langel-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > I''ve taken a more indepth look at this issue. Looks like a FF3b2 > regression.Good work, Tobie! :Dan Dorman --~--~---------~--~----~------------~-------~--~----~ 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 has done it again http://dev.rubyonrails.org/changeset/8537 :) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Jan 2, 2008 8:45 PM, kangax <kangax-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Tobie has done it again http://dev.rubyonrails.org/changeset/8537 :)Very cool. :Dan --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---