[Proto-Scripty] Re: Cross-browser function for Text content

2010-04-21 Thread T.J. Crowder
Hi, On Apr 21, 3:38 pm, Rüdiger Plantiko wrote: > > Surprisingly, IE8 still doesn't support it, but even if it did, > > frankly it doesn't do what _I'd_ want. > > Does IE8 claim to be HTML5 compliant? I doubt it (it would be quite a trick as the HTML5 working group hasn't even stopped accepting

[Proto-Scripty] Re: Cross-browser function for Text content

2010-04-21 Thread Rüdiger Plantiko
Hi Eric and TJ, thanks for your further research in this matter! > Surprisingly, IE8 still doesn't support it, but even if it did, > frankly it doesn't do what _I'd_ want. Does IE8 claim to be HTML5 compliant? > $('test').textContent || $('test').innerText > The only drawback I can think of i

[Proto-Scripty] Re: Cross-browser function for Text content

2010-04-15 Thread T.J. Crowder
Interestingly, Firefox's `textContent` behavior of including the script element's contents (which I called "insanity") is *standard* as far as I can tell -- and has been for years: http://www.w3.org/TR/html5/infrastructure.html#textcontent http://www.w3.org/TR/DOM-Level-3-Core/core.html#Node3-text

[Proto-Scripty] Re: Cross-browser function for Text content

2010-04-13 Thread T.J. Crowder
Hi, On Apr 13, 2:42 pm, kangax wrote: > We've been getting these requests in the past. Take a look at, for > example: > http://groups.google.com/group/prototype-core/browse_thread/thread/8e...> > > I still think that it's not a trivial solution (for the reasons > outlined in the post linked abov

[Proto-Scripty] Re: Cross-browser function for Text content

2010-04-13 Thread kangax
We've been getting these requests in the past. Take a look at, for example: http://groups.google.com/group/prototype-core/browse_thread/thread/8ef26e7cedb43afc/47033b4bc8dc4c74#47033b4bc8dc4c74> I still think that it's not a trivial solution (for the reasons outlined in the post linked above) and

[Proto-Scripty] Re: Cross-browser function for Text content

2010-04-13 Thread T.J. Crowder
On Apr 13, 10:39 am, Eric wrote: > wouldn't it be wiser to check for the native method once and use it? Probably. I'd also check for innerText (in fact, I'd check for that first), since it's supported by IE, WebKit (so Chrome, Safari), and Opera; only Mozilla holds out. textContent is supported b

[Proto-Scripty] Re: Cross-browser function for Text content

2010-04-13 Thread Eric
Oooops, gmail sent the message before I finished... :o) Here is the correct message (please ignore the previous one) On Apr 12, 7:04 pm, "T.J. Crowder" wrote: > Element.addMethods({ >     text: function(element) { >         if (!(element = $(element))) return; >         return element.innerHTML

[Proto-Scripty] Re: Cross-browser function for Text content

2010-04-13 Thread Eric
On Apr 12, 7:04 pm, "T.J. Crowder" wrote: > Element.addMethods({ >     text: function(element) { >         if (!(element = $(element))) return; >         return element.innerHTML.stripTags(); >     } > > }); wouldn't it be wiser to check for the native method once and use it? Something like (u

[Proto-Scripty] Re: Cross-browser function for Text content

2010-04-13 Thread Eric
What I use in this case is: $('test').textContent || $('test').innerText If textContent is defined, it is used. if it isn't, innerText is used. This would be a lot faster than stripping tags. The only drawback I can think of is that sometime you may get an undefined instead of an empty string (whi

[Proto-Scripty] Re: Cross-browser function for Text content

2010-04-12 Thread Rüdiger Plantiko
Hi TJ, > > I get the number 4711 in IE with $("test").innerText and in FF with $ > > ("test").textContent - does Prototype provide a browser-independent > > abstraction for this? > > Hopefully you get the *string* "4711" rather than the number 4711 > (unless you parse it). :-) You are right, in a

[Proto-Scripty] Re: Cross-browser function for Text content

2010-04-12 Thread T.J. Crowder
Hi, > I get the number 4711 in IE with $("test").innerText and in FF with $ > ("test").textContent - does Prototype provide a browser-independent > abstraction for this? Hopefully you get the *string* "4711" rather than the number 4711 (unless you parse it). :-) `innerHTML` works on all major br