[jQuery] Re: $("something").text() doesn't preserve whitespace in IE

2008-07-08 Thread alistairholt

Thanks for opening the ticket. I could use that but I don't think it
would give me what I'm looking for.. my  is full of HTML junk
(needed for syntax highlighting) from Textmate. Have a look at
http://pastie.org/230104 for an example.

On 8 Jul, 15:55, Dave Methvin <[EMAIL PROTECTED]> wrote:
> > The problem for me is that using text() in IE 6/7 doesn't preserve
> > whitespace...
>
> As a workaround, you can use an expression like this:
>
> var pre = $("").get(0);
>
> alert(pre.innerText || pre.textContent);
>
> All the browsers seem to support one property or the other--or both.
> Their text output isn't exactly the same in all cases, but at least
> there's some sort of whitespace.
>
> The additional case that jQuery's .text() has to handle is XML, where
> neither of these properties are available. I guess that's why it
> wasn't used.
>
> I opened a ticket:http://dev.jquery.com/ticket/3144


[jQuery] Re: $("something").text() doesn't preserve whitespace in IE

2008-07-08 Thread Dave Methvin

> The problem for me is that using text() in IE 6/7 doesn't preserve
> whitespace...

As a workaround, you can use an expression like this:

var pre = $("").get(0);

alert(pre.innerText || pre.textContent);

All the browsers seem to support one property or the other--or both.
Their text output isn't exactly the same in all cases, but at least
there's some sort of whitespace.

The additional case that jQuery's .text() has to handle is XML, where
neither of these properties are available. I guess that's why it
wasn't used.

I opened a ticket:
http://dev.jquery.com/ticket/3144


[jQuery] Re: $("something").text() doesn't preserve whitespace in IE

2008-07-08 Thread alistairholt

The problem for me is that using text() in IE 6/7 doesn't preserve
whitespace...

On 8 Jul, 04:22, Dave Methvin <[EMAIL PROTECTED]> wrote:
> > Results are athttp://pastie.org/228916
>
> The code for jQuery.text has changed a lot in two years, but those
> test results still look pretty familiar... :-)


[jQuery] Re: $("something").text() doesn't preserve whitespace in IE

2008-07-07 Thread Dave Methvin


> Results are at http://pastie.org/228916

The code for jQuery.text has changed a lot in two years, but those
test results still look pretty familiar... :-)


[jQuery] Re: $("something").text() doesn't preserve whitespace in IE

2008-07-07 Thread alistairholt

html() would be no good for what I'm trying to do. Basically I have
 blocks which contain pre-formatted source code (including a lot
of extra html spans and what not for syntax highlighting and line
numbering). I then take the text() of the 's and insert it into a
 which will now contain a plain text version of the code
from the . Works perfectly in anything but IE.

On 7 Jul, 12:49, "Dan G. Switzer, II" <[EMAIL PROTECTED]> wrote:
> >I'm having some issues when calling $("something").text() in IE 6/7.
> >Basically I'm getting the calling text() on a  element which is
> >whitespace sensitive. In Firefox and Safari it works perfectly
> >returning the text with whitespace intact. Is it possible to make it
> >work in IE or shall I give up?
>
> Have you tried using html() instead?
>
> -Dan


[jQuery] Re: $("something").text() doesn't preserve whitespace in IE

2008-07-07 Thread Dan G. Switzer, II

>I'm having some issues when calling $("something").text() in IE 6/7.
>Basically I'm getting the calling text() on a  element which is
>whitespace sensitive. In Firefox and Safari it works perfectly
>returning the text with whitespace intact. Is it possible to make it
>work in IE or shall I give up?

Have you tried using html() instead?

-Dan



[jQuery] Re: $("something").text() doesn't preserve whitespace in IE

2008-07-07 Thread alistairholt

Results are at http://pastie.org/228916

On 7 Jul, 01:17, "John Resig" <[EMAIL PROTECTED]> wrote:
> I'm fairly certain that our .text() support has changed a lot since
> October 2006 (!). It would be interesting to re-examine this issue -
> if there are any current problems I know that we'd really like to get
> them fixed.
>
> --John
>
> On Sun, Jul 6, 2008 at 8:05 PM, Dave Methvin <[EMAIL PROTECTED]> wrote:
>
> >> I'm having some issues when calling $("something").text() in IE 6/7.
> >> Basically I'm getting the calling text() on a  element which is
> >> whitespace sensitive. In Firefox and Safari it works perfectly
> >> returning the text with whitespace intact. Is it possible to make it
> >> work in IE or shall I give up?
>
> > I noticed that too quite a while back, if you run the test in this
> > message does it still do the same thing?
>
> >http://www.nabble.com/.text()-method-quirks-p6933512s27240.html


[jQuery] Re: $("something").text() doesn't preserve whitespace in IE

2008-07-07 Thread alistairholt

Thanks guys. I'll run the test and post the results ASAP.

On Jul 7, 1:17 am, "John Resig" <[EMAIL PROTECTED]> wrote:
> I'm fairly certain that our .text() support has changed a lot since
> October 2006 (!). It would be interesting to re-examine this issue -
> if there are any current problems I know that we'd really like to get
> them fixed.
>
> --John
>
> On Sun, Jul 6, 2008 at 8:05 PM, Dave Methvin <[EMAIL PROTECTED]> wrote:
>
> >> I'm having some issues when calling $("something").text() in IE 6/7.
> >> Basically I'm getting the calling text() on a  element which is
> >> whitespace sensitive. In Firefox and Safari it works perfectly
> >> returning the text with whitespace intact. Is it possible to make it
> >> work in IE or shall I give up?
>
> > I noticed that too quite a while back, if you run the test in this
> > message does it still do the same thing?
>
> >http://www.nabble.com/.text()-method-quirks-p6933512s27240.html


[jQuery] Re: $("something").text() doesn't preserve whitespace in IE

2008-07-06 Thread John Resig

I'm fairly certain that our .text() support has changed a lot since
October 2006 (!). It would be interesting to re-examine this issue -
if there are any current problems I know that we'd really like to get
them fixed.

--John


On Sun, Jul 6, 2008 at 8:05 PM, Dave Methvin <[EMAIL PROTECTED]> wrote:
>
>> I'm having some issues when calling $("something").text() in IE 6/7.
>> Basically I'm getting the calling text() on a  element which is
>> whitespace sensitive. In Firefox and Safari it works perfectly
>> returning the text with whitespace intact. Is it possible to make it
>> work in IE or shall I give up?
>
> I noticed that too quite a while back, if you run the test in this
> message does it still do the same thing?
>
> http://www.nabble.com/.text()-method-quirks-p6933512s27240.html
>


[jQuery] Re: $("something").text() doesn't preserve whitespace in IE

2008-07-06 Thread Dave Methvin

> I'm having some issues when calling $("something").text() in IE 6/7.
> Basically I'm getting the calling text() on a  element which is
> whitespace sensitive. In Firefox and Safari it works perfectly
> returning the text with whitespace intact. Is it possible to make it
> work in IE or shall I give up?

I noticed that too quite a while back, if you run the test in this
message does it still do the same thing?

http://www.nabble.com/.text()-method-quirks-p6933512s27240.html