List Info

Thread: Firefox 3 Beta 2 & Element.insert()




Firefox 3 Beta 2 & Element.insert()
user name
2007-12-20 11:49:12
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!

an
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-spinoffsgooglegroups.com
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribegooglegroups.com
For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=
en
-~----------~----~----~----~------~----~------~--~---


Re: Firefox 3 Beta 2 & Element.insert()
user name
2007-12-20 12:49:16
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.dormangmail.com">dan.dormangmail.com> 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&gt;

JS:
document.observe('dom:loaded';, function() {
 try {
   $(&#39;foo').insert(new Element(&#39;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(&#39;p'));
p.insert('hello, world');

2. Use update instead of insert, that is:
$(';foo').insert(new Element(&#39;p').update(';hello, world'));

3. Insert the explicit HTML, even though I'd prefer not to; that is:
$(&#39;foo').insert(&#39;<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 anybody9;s got an explanation for what's going
on here, I'd love to hear it!

an Dorman
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs&quot; group.
To post to this group, send email to rubyonrails-spinoffsgooglegroups.com
To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribegooglegroups.com
For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---

Re: Firefox 3 Beta 2 & Element.insert()
user name
2007-12-20 14:55:21
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-spinoffsgooglegroups.com
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribegooglegroups.com
For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=
en
-~----------~----~----~----~------~----~------~--~---


Re: Firefox 3 Beta 2 & Element.insert()
user name
2007-12-20 17:35:51
On Dec 20, 2007 11:49 AM, Kurt Cagle <kurt.caglegmail.com> 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_3

Thanks 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 <kangaxgmail.com> 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!

an
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-spinoffsgooglegroups.com
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribegooglegroups.com
For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=
en
-~----------~----~----~----~------~----~------~--~---


Re: Firefox 3 Beta 2 & Element.insert()
user name
2007-12-21 06:30:06
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:

h
ttps://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-spinoffsgooglegroups.com
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribegooglegroups.com
For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=
en
-~----------~----~----~----~------~----~------~--~---


Re: Firefox 3 Beta 2 & Element.insert()
user name
2007-12-21 10:55:41
On Dec 21, 2007 5:30 AM, Tobie Langel <tobie.langelgmail.com> wrote:
>
> I've taken a more indepth look at this issue. Looks
like a FF3b2
> regression.

Good work, Tobie!

an
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-spinoffsgooglegroups.com
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribegooglegroups.com
For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=
en
-~----------~----~----~----~------~----~------~--~---


Re: Firefox 3 Beta 2 & Element.insert()
user name
2008-01-02 21:45:42
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-spinoffsgooglegroups.com
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribegooglegroups.com
For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=
en
-~----------~----~----~----~------~----~------~--~---


Re: Firefox 3 Beta 2 & Element.insert()
user name
2008-01-02 23:38:49
On Jan 2, 2008 8:45 PM, kangax <kangaxgmail.com> wrote:
>
> Tobie has done it again http://dev.
rubyonrails.org/changeset/8537 

Very cool.

an

--~--~---------~--~----~------------~-------~--~----~
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-spinoffsgooglegroups.com
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribegooglegroups.com
For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=
en
-~----------~----~----~----~------~----~------~--~---


[1-8]

about | contact  Other archives ( Real Estate discussion Medical topics )