Hey cats, I seem to have ran into a problem in IE trying to use parentNode with the cleanWhitespace method. doing something like: var div = $(''mydiv''); Element.cleanWhitespace(div); works really great, but try doing: var div = $(''mydiv''); Element.cleanWhitespace(div.parentNode); or var div = $(''mydiv''); div = div.parentNode; Element.cleanWhitespace(div); Breaks in IE, I''ve been messing around with alerts in prototype and it looks like it''s going through the for loop in the cleanWhitespace method at least once, but then it breaks on a consecutive pass through. Any idea why this is, or anyway to hack around it? (this isn''t a problem in Firefox or Safari, btw) Thanks for you help, Jason
Meow...er I mean, why not just select the $(''parentNode'') in the first place? On 4/27/06, Jason Hummel <jhummel-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Hey cats, > > I seem to have ran into a problem in IE trying to use parentNode with > the cleanWhitespace method. > > doing something like: > > var div = $(''mydiv''); > Element.cleanWhitespace(div); > > works really great, but try doing: > > var div = $(''mydiv''); > Element.cleanWhitespace(div.parentNode); > > or > > var div = $(''mydiv''); > div = div.parentNode; > Element.cleanWhitespace(div); > > Breaks in IE, I''ve been messing around with alerts in prototype and it > looks like it''s going through the for loop in the cleanWhitespace > method at least once, but then it breaks on a consecutive pass > through. Any idea why this is, or anyway to hack around it? (this > isn''t a problem in Firefox or Safari, btw) > > Thanks for you help, > Jason > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs >_______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
On 4/27/06, Steve Longdo <steve.longdo-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Meow...er I mean, why not just select the $(''parentNode'') in the first > place?I actually tried that as well: var div = $(''mydiv'').parentNode; Element.cleanWhitespace(div); and got nada on IE
try var div = $($(''mydiv'').parentNode.id); Element.cleanWhitespace(div); ...make sure the parentNode element actually has an id. It may be there is a bit of a difference between the reference you get from document.getElementById and trying to access a node (or nodeset) directly. On 4/27/06, Jason Hummel <jhummel-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > On 4/27/06, Steve Longdo <steve.longdo-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Meow...er I mean, why not just select the $(''parentNode'') in the first > > place? > > I actually tried that as well: > > var div = $(''mydiv'').parentNode; > Element.cleanWhitespace(div); > > and got nada on IE > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs >_______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
What actually IS the parentnode? Perhaps its one of those "we''ll render this element tag implicitly in firefox" issues (a la <tbody>)? On 4/27/06, Ryan Gahl <ryan.gahl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > try > > var div = $($(''mydiv'').parentNode.id); > Element.cleanWhitespace(div); > > ...make sure the parentNode element actually has an id. It may be there is > a bit of a difference between the reference you get from > document.getElementById and trying to access a node (or nodeset) directly. > > On 4/27/06, Jason Hummel <jhummel-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org > wrote: > > > On 4/27/06, Steve Longdo <steve.longdo-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org > wrote: > > > Meow...er I mean, why not just select the $(''parentNode'') in the first > > > place? > > > > I actually tried that as well: > > > > var div = $(''mydiv'').parentNode; > > Element.cleanWhitespace(div); > > > > and got nada on IE > > _______________________________________________ > > Rails-spinoffs mailing list > > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > >_______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
> What actually IS the parentnode? Perhaps its one of those "we''ll render this > element tag implicitly in firefox" issues (a la <tbody>)?The parentnode is a div with an ID. I''ve got something crazy going on here. div.parentNode doesn''t work, but div.parentNode.parentNode works fine. If I put the actual ID into the cleanWhitespace: Element.cleanWhitespace(''myDiv''); It doesn''t work in IE, but putting in any other id and IE seems to execute it just fine. It doesn''t seem to matter what is in the ID or what the name of the ID is.. I used the firefox view formatted source extension to grab all my rendered HTML and there doesn''t seem to be any elements not closed or anything like that. I''ll dig further. Thanks for the help everyone.
You happen to have that ID as a "name" attribute anywhere else in the page? On 4/27/06, Jason Hummel <jhummel-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > What actually IS the parentnode? Perhaps its one of those "we''ll render > this > > element tag implicitly in firefox" issues (a la <tbody>)? > > The parentnode is a div with an ID. I''ve got something crazy going on > here. div.parentNode doesn''t work, but div.parentNode.parentNode works > fine. If I put the actual ID into the cleanWhitespace: > > Element.cleanWhitespace(''myDiv''); > > It doesn''t work in IE, but putting in any other id and IE seems to > execute it just fine. It doesn''t seem to matter what is in the ID or > what the name of the ID is.. I used the firefox view formatted source > extension to grab all my rendered HTML and there doesn''t seem to be > any elements not closed or anything like that. I''ll dig further. > Thanks for the help everyone. > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs >_______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Using prototype 1.5.0_rc0? The problem is Element.cleanWhiteSpace() calls Element.remove() on empty textnodes. Element.remove tries to extend the element (Element.Methods) and IE doesn''t support this.... I''ve opened a ticket some time ago.... http://dev.rubyonrails.org/ticket/4642 There is also a simple workaround ... hth On 4/27/06, Jerod Venema <jvenema-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > You happen to have that ID as a "name" attribute anywhere else in the > page? > > On 4/27/06, Jason Hummel <jhummel-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org > wrote: > > > > What actually IS the parentnode? Perhaps its one of those "we''ll > > render this > > > element tag implicitly in firefox" issues (a la <tbody>)? > > > > The parentnode is a div with an ID. I''ve got something crazy going on > > here. div.parentNode doesn''t work, but div.parentNode.parentNode works > > fine. If I put the actual ID into the cleanWhitespace: > > > > Element.cleanWhitespace(''myDiv''); > > > > It doesn''t work in IE, but putting in any other id and IE seems to > > execute it just fine. It doesn''t seem to matter what is in the ID or > > what the name of the ID is.. I used the firefox view formatted source > > extension to grab all my rendered HTML and there doesn''t seem to be > > any elements not closed or anything like that. I''ll dig further. > > Thanks for the help everyone. > > _______________________________________________ > > Rails-spinoffs mailing list > > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > >-- Mit freundlichen Grüßen Siegfried Puchbauer _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Another thing to watch for (though maybe we got to the bottom of this already) is that IDs cant start with a number. I.e. id="0123123" is invalid, and can lead to strange errors like the one you describe. If your id is actually "myDiv", there''s no problem, but I''ve seen lots of people try and use a guid, and thats no good - you need to add a prefix. See: http://www.w3.org/TR/REC-html40/types.html#type-name "ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods (".")." hth, Sam>Element.cleanWhitespace(''myDiv''); > >It doesn''t work in IE, but putting in any other id and IE seems to >execute it just fine. It doesn''t seem to matter what is in the ID or >what the name of the ID is.. I used the firefox view formatted source >extension to grab all my rendered HTML and there doesn''t seem to be >any elements not closed or anything like that. I''ll dig further. >Thanks for the help everyone. > >
That was it! I swapped out the Element.remove for node.parentNode.remove and it worked. Thanks so much, very helpful. On 4/27/06, Siegfried Puchbauer <siegfried.puchbauer-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Using prototype 1.5.0_rc0? > > The problem is Element.cleanWhiteSpace() calls Element.remove() on empty > textnodes. Element.remove tries to extend the element (Element.Methods) and > IE doesn''t support this.... > > I''ve opened a ticket some time ago.... > > http://dev.rubyonrails.org/ticket/4642 > > There is also a simple workaround ... > > hth > > > On 4/27/06, Jerod Venema <jvenema-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > You happen to have that ID as a "name" attribute anywhere else in the > page? > > > > > > > > On 4/27/06, Jason Hummel <jhummel-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org > wrote: > > > > > > What actually IS the parentnode? Perhaps its one of those "we''ll > render this > > > > element tag implicitly in firefox" issues (a la <tbody>)? > > > > > > The parentnode is a div with an ID. I''ve got something crazy going on > > > here. div.parentNode doesn''t work, but div.parentNode.parentNode works > > > fine. If I put the actual ID into the cleanWhitespace: > > > > > > Element.cleanWhitespace(''myDiv''); > > > > > > It doesn''t work in IE, but putting in any other id and IE seems to > > > execute it just fine. It doesn''t seem to matter what is in the ID or > > > what the name of the ID is.. I used the firefox view formatted source > > > extension to grab all my rendered HTML and there doesn''t seem to be > > > any elements not closed or anything like that. I''ll dig further. > > > Thanks for the help everyone. > > > _______________________________________________ > > > Rails-spinoffs mailing list > > > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > > > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > > > > > > > > > _______________________________________________ > > Rails-spinoffs mailing list > > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > > > > > > > > -- > Mit freundlichen Grüßen > > Siegfried Puchbauer > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > >
On 4/27/06, Siegfried Puchbauer <siegfried.puchbauer-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> The problem is Element.cleanWhiteSpace() calls Element.remove() on empty > textnodes. Element.remove tries to extend the element (Element.Methods) and > IE doesn''t support this....So prototype now burns cycles to extend an element that it is going to throw away on the next instruction?
Why not write a patch? -Thomas Am 28.04.2006 um 11:02 schrieb Martin Bialasinski:> On 4/27/06, Siegfried Puchbauer <siegfried.puchbauer-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> The problem is Element.cleanWhiteSpace() calls Element.remove() on >> empty >> textnodes. Element.remove tries to extend the element >> (Element.Methods) and >> IE doesn''t support this.... > > So prototype now burns cycles to extend an element that it is going to > throw away on the next instruction?
On 4/28/06, Thomas Fuchs <t.fuchs-moWQItti3gBl57MIdRCFDg@public.gmane.org> wrote:> Why not write a patch?I froze my Prototype version just prior to the change to $(). Currently, I need stability and this is too much a change in the fundamental workings of the library. The last thing I need are nasty surprises, which there were and might still show up. Therefore, I pass up on that. Additionally, what good are patches, when even the trivial ones on Prototype just keep rotting in Trac? Does Sam even care? http://dev.rubyonrails.org/query?status=new&status=assigned&status=reopened&component=Prototype&summary=%7EPatch&order=id The whole $() business is syntactic sugar, this was no pressing issue. A much better OOP implementation, like described in http://dev.rubyonrails.org/ticket/4060 , has much more value, IMHO. And Sam did not even bother to say one word on this great contribution.
Cause I havn''t figured out what the best way is to prevent the error ... Cheers, Sigi On 4/28/06, Thomas Fuchs <t.fuchs-moWQItti3gBl57MIdRCFDg@public.gmane.org> wrote:> > Why not write a patch? > -Thomas > > Am 28.04.2006 um 11:02 schrieb Martin Bialasinski: > > > On 4/27/06, Siegfried Puchbauer <siegfried.puchbauer-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > >> The problem is Element.cleanWhiteSpace() calls Element.remove() on > >> empty > >> textnodes. Element.remove tries to extend the element > >> (Element.Methods) and > >> IE doesn''t support this.... > > > > So prototype now burns cycles to extend an element that it is going to > > throw away on the next instruction? > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs >-- Mit freundlichen Grüßen Siegfried Puchbauer _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
On 4/28/06, Martin Bialasinski <klingeling-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 4/28/06, Thomas Fuchs <t.fuchs-moWQItti3gBl57MIdRCFDg@public.gmane.org> wrote: > > > Why not write a patch? > > I froze my Prototype version just prior to the change to $(). > Currently, I need stability and this is too much a change in the > fundamental workings of the library. The last thing I need are nasty > surprises, which there were and might still show up. Therefore, I pass > up on that. Additionally, what good are patches, when even the trivial > ones on Prototype just keep rotting in Trac? Does Sam even care?Martin, I couldn''t agree with you more. I quit submitting patches for bugs and assisting others through dev.rubyonrails.org because there was virtually NO response from the Prototype devs. For every patch that''s been committed, there are three others that are sitting with no feedback. I''ve tried contacting Sam via his personal e-mail address as well, to no avail. Neglectful maintainers are worked around by forking (although I''m not advocating such a position ... yet). Todd