Discussion:
[chromium-bugs] Issue 536137 in chromium: Element.innerText actually returns Element.textContent in documents returned by XMLHttpRequest
c***@googlecode.com
2015-09-25 20:15:50 UTC
Permalink
Status: Unconfirmed
Owner: ----
Labels: Cr-Blink-JavaScript Pri-2 Via-Wizard Type-Bug OS-Windows

New issue 536137 by ***@gmail.com: Element.innerText actually
returns Element.textContent in documents returned by XMLHttpRequest
https://code.google.com/p/chromium/issues/detail?id=536137

UserAgent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like
Gecko) Chrome/47.0.2519.0 Safari/537.36

Steps to reproduce the problem:
1. Open the page:

https://developer.mozilla.org/en-US/docs/Web/API/Node/innerText

2. Execute in the console:

const node1 = document.querySelector('#wiki-document-head');
console.log(JSON.stringify(node1.innerText));
console.log(JSON.stringify(node1.textContent));
console.log(node1.innerText === node1.textContent);

const xhr = new XMLHttpRequest();
xhr.open('GET', location.href, true);
xhr.responseType = 'document';
xhr.withCredentials = true;
xhr.onload = function() {
const node2 = this.response.querySelector('#wiki-document-head');
console.log(JSON.stringify(node2.innerText));
console.log(JSON.stringify(node2.textContent));
console.log(node2.innerText === node2.textContent);
};
xhr.ontimeout = xhr.onerror = function(evt) {
console.log(evt.type);
};
xhr.send(null);

What is the expected behavior?
When you do it in the IE 11.0.14, the output is:

" \r\n\r\nYour Search Results\r\n \r\nNode.innerText\r\n\r\n by 1
contributor: \r\n "

"\n \n \n \n \n
\n \n \n Your Search Results\n
\n \n \n \n \n\n
Node.innerText\n\n \n \n \n by
1 contributor: \n \n
\n \n \n
\n \n \n \n "

false

" \r\nYour Search Results \r\nNode.innerText\r\n\r\nby 1 contributor:
cvrebert "

"\n \n \n \n \n
\n \n \n Your Search Results\n
\n \n \n \n \n\n
Node.innerText\n\n \n \n \n by
1 contributor: \n \n
\n \n cvrebert\n
\n \n \n \n "

false

What went wrong?
When you do it in the Google Chrome 47.0.2519.0 Canary, the output is:

"Node.innerText\n\nby 1 contributor: \n"

"\n \n \n \n \n
\n \n \n Your Search Results\n
\n \n \n \n \n\n
Node.innerText\n\n \n \n \n by
1 contributor: \n \n
\n \n \n
\n \n \n \n "

false

"\n \n \n \n \n
\n \n \n Your Search Results\n
\n \n \n \n \n\n
Node.innerText\n\n \n \n \n by
1 contributor: \n \n
\n \n cvrebert\n
\n \n \n \n "

"\n \n \n \n \n
\n \n \n Your Search Results\n
\n \n \n \n \n\n
Node.innerText\n\n \n \n \n by
1 contributor: \n \n
\n \n cvrebert\n
\n \n \n \n "

true

Did this work before? N/A

Chrome version: 47.0.2519.0 Channel: canary
OS Version: 6.1 (Windows 7, Windows Server 2008 R2)
Flash Version: Shockwave Flash 19.0 r0

There is a wonderful article about usefulness of negligible innerText in
many cases:

http://perfectionkills.com/the-poor-misunderstood-innerText/

It's a pity we can't use innerText in the XMLHttpRequest in the Google
Chrome.

The author suggests getSelection().toString() as a very slow workaround,
but getSelection() is not implemented for XMLHttpRequest because of lacking
window object. If we add these string to the previous code:

console.log(document.defaultView);

console.log(this.response.defaultView);

We get:

In the IE 11.0.14: [object Window] null

In the Google Chrome 47.0.2519.0 Canary: Window null

May be in the Google Chrome innerText depends on Window object, while in
the IE innerText is independent.
--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings
--
--
Automated mail from issue updates at http://crbug.com/
Subscription options: http://groups.google.com/a/chromium.org/group/chromium-bugs

To unsubscribe from this group and stop receiving emails from it, send an email to chromium-bugs+***@chromium.org.
c***@googlecode.com
2015-09-25 21:51:01 UTC
Permalink
Updates:
Status: Untriaged
Cc: ***@chromium.org ***@chromium.org ***@chromium.org
Labels: -Type-Bug -OS-Windows Type-Feature OS-All

Comment #1 on issue 536137 by ***@chromium.org: Element.innerText
actually returns Element.textContent in documents returned by XMLHttpRequest
https://code.google.com/p/chromium/issues/detail?id=536137

Followed steps given by user and same behavior is observed in Chrome
47.0.2519.0 canary & 45.0.2454.101 stable, 44.0.2403.157 - Windows 7.

CCing few dev's who might know more about this issue. For now marking as
Type-Feature. Please change if its not relevant.
--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings
--
--
Automated mail from issue updates at http://crbug.com/
Subscription options: http://groups.google.com/a/chromium.org/group/chromium-bugs

To unsubscribe from this group and stop receiving emails from it, send an email to chromium-bugs+***@chromium.org.
c***@googlecode.com
2015-09-25 21:54:00 UTC
Permalink
Updates:
Labels: Needs-Feedback

Comment #2 on issue 536137 by ***@chromium.org: Element.innerText
actually returns Element.textContent in documents returned by XMLHttpRequest
https://code.google.com/p/chromium/issues/detail?id=536137

(No comment was entered for this change.)
--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings
--
--
Automated mail from issue updates at http://crbug.com/
Subscription options: http://groups.google.com/a/chromium.org/group/chromium-bugs

To unsubscribe from this group and stop receiving emails from it, send an email to chromium-bugs+***@chromium.org.
c***@googlecode.com
2015-09-28 00:42:35 UTC
Permalink
Updates:
Cc: -***@chromium.org -***@chromium.org ***@chromium.org
Labels: -Cr-Blink-JavaScript Cr-Blink-DOM

Comment #3 on issue 536137 by ***@chromium.org: Element.innerText
actually returns Element.textContent in documents returned by XMLHttpRequest
https://code.google.com/p/chromium/issues/detail?id=536137

(No comment was entered for this change.)
--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings
--
--
Automated mail from issue updates at http://crbug.com/
Subscription options: http://groups.google.com/a/chromium.org/group/chromium-bugs

To unsubscribe from this group and stop receiving emails from it, send an email to chromium-bugs+***@chromium.org.
c***@googlecode.com
2015-10-01 06:08:20 UTC
Permalink
Updates:
Status: Available
Labels: -Type-Feature -Needs-Feedback Type-Bug

Comment #4 on issue 536137 by ***@chromium.org: Element.innerText
actually returns Element.textContent in documents returned by XMLHttpRequest
https://code.google.com/p/chromium/issues/detail?id=536137

OK, here [1] is the offending statement. innerText causes layout, which is
how it knows about generated content and line breaks and stuff, but I'm
guessing an XHR document can't do layout because it doesn't have all of the
frame machinery to make that go.

I guess if we're going to support nonstandard properties we should at least
make them work interoperably.

[1]
https://code.google.com/p/chromium/codesearch#chromium/src/third_party/WebKit/Source/core/dom/Element.cpp&sq=package:chromium&l=2628&rcl=1443641225
--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings
--
--
Automated mail from issue updates at http://crbug.com/
Subscription options: http://groups.google.com/a/chromium.org/group/chromium-bugs

To unsubscribe from this group and stop receiving emails from it, send an email to chromium-bugs+***@chromium.org.
c***@googlecode.com
2015-10-02 03:34:18 UTC
Permalink
Updates:
Labels: Cr-Blink-Editing

Comment #5 on issue 536137 by ***@chromium.org: Element.innerText
actually returns Element.textContent in documents returned by XMLHttpRequest
https://code.google.com/p/chromium/issues/detail?id=536137

Labeled Cr-Blink-Editing, since current implementation of Element.innerText
depends
on TextIterator. We would like to change situation like [1] in #c4.
--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings
--
--
Automated mail from issue updates at http://crbug.com/
Subscription options: http://groups.google.com/a/chromium.org/group/chromium-bugs

To unsubscribe from this group and stop receiving emails from it, send an email to chromium-bugs+***@chromium.org.
c***@googlecode.com
2015-11-04 07:55:59 UTC
Permalink
Comment #6 on issue 536137 by ***@chromium.org: Element.innerText
actually returns Element.textContent in documents returned by XMLHttpRequest
https://code.google.com/p/chromium/issues/detail?id=536137

The spec for innerText is discussed in
https://github.com/whatwg/compat/issues/5
--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings
--
--
Automated mail from issue updates at http://crbug.com/
Subscription options: http://groups.google.com/a/chromium.org/group/chromium-bugs

To unsubscribe from this group and stop receiving emails from it, send an email to chromium-bugs+***@chromium.org.
Loading...