New issue
Advanced search Search tips

Issue 637153 link

Starred by 1 user

Issue metadata

Status: WontFix
Owner: ----
Closed: Aug 2016
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 2
Type: Bug



Sign in to add a comment

Escaped noscript in innerText of invisible element

Project Member Reported by wychen@chromium.org, Aug 12 2016

Issue description

Version: M53

What steps will reproduce the problem?
(1) Create a page with this HTML:
  <div id="test">
    <noscript>
      <span>text in noscript</span>
    </noscript>
    <p>normal text</p>
  </div>
  <div id="test2" style="display: none">
    <noscript>
      <span>text in noscript</span>
    </noscript>
    <p>normal text</p>
  </div>

(2) Disable JavaScript, and run this code in console:
  console.debug(document.getElementById('test').innerText)
  console.debug(document.getElementById('test2').innerText)

(3) Enable JavaScript, and rerun the code

What is the expected output?

innerText is not well defined in the spec, so it's hard to say what the expected behavior is.
However, escaping the the content in <noscript> seems wrong.

Regarding <noscript> in .innerText when JS is enabled, there are a few possibilities:
- Ignore this element
- Show its .innerText as if JS is disabled
- Show its .textContent (current behavior)

Either one of the first two possibilities is better than the current behavior.

What do you see instead?

With JavaScript disabled, the output is:

<pre>
text in noscript
normal text
    
      text in noscript
    
    normal text
</pre>

This is expected.

With JavaScript enabled, the output is:

<pre>
normal text
    
      <span>text in noscript</span>
    
    normal text
</pre>
Seeing escaped <span> is not expected.

 

Comment 2 by wychen@chromium.org, Aug 12 2016

Cc: yosin@chromium.org

Comment 3 by tkent@chromium.org, Aug 12 2016

Cc: tkent@chromium.org
Status: WontFix (was: Untriaged)
Both of Edge and Firefox has the same behavior.
<noscript> can't contains tags if scripting is enabled.

https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inbody
> ➔ A start tag whose tag name is "noscript", if the scripting flag is enabled
>    Follow the generic raw text element parsing algorithm.

Sign in to add a comment