Open Bug 1404675 Opened 3 years ago Updated 3 years ago

innerText should ignore "invisible" break when serializing HTML fragment

Categories

(Core :: DOM: Core & HTML, defect, P3)

defect

Tracking

()

UNCONFIRMED
Tracking Status
firefox-esr52 --- affected

People

(Reporter: subs, Unassigned)

References

()

Details

Attachments

(1 file)

Attached file innertext_test.html
User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:58.0) Gecko/20100101 Firefox/58.0
Build ID: 20170930220116

Steps to reproduce:

Set innerText of element to itself.


Actual results:

The newlines in the text changed (incorrectly relative to what was displayed previously).


Expected results:

The element shouldn't have changed, because the HTML was identical to what was there previously.

The attached test case shows what happens. Clicking 'Rewrite' just sets el.innerText = el.innerText, and the display/content of the div will change when it shouldn't.

Note that this works correctly in Chrome and in the current release version Firefox, but not on Nightly.
Note that I copied (via the JS console) what Firefox sets as the div content when you manually type it in, just so the test case starts off at the right point. You could of course type in what's there and then hit 'Rewrite' to get the same problem to happen.
Hi Reporter, thank you for reporting the issue. Would you minding helping us get where this regressed from by the mozregression tool [1]?  Thank you.

[1] https://blog.nightly.mozilla.org/category/mozregression/
Flags: needinfo?(subs)
Masayuki did a bunch of work improving innerText performance over in the tree of bugs rooted at bug 1346723. Maybe he has an idea of what changed here?
Flags: needinfo?(masayuki)
Keywords: regression
Priority: -- → P1
I see this bug even with ESR52. So, this is not a recent regression. (Could be really old bug since setting innerHTML causes converting <div> to <br>. I have no idea when such big change occurs if older build didn't this conversion.)
Flags: needinfo?(masayuki)
Oops, not innertHTML, the testcase uses innerText.
According to quick testing on the testcase, end tab of <div> causes "\n" at getting innerText but <div><br></div> causes "\n\n" and <div>abc<br></div> also causes "abc\n\n". Like editor, innerText should ignore "invisible" break when serializing HTML fragment.
(In reply to Masayuki Nakano [:masayuki] (JST, +0900) from comment #4)
> I see this bug even with ESR52. So, this is not a recent regression. (Could
> be really old bug since setting innerHTML causes converting <div> to <br>. I
> have no idea when such big change occurs if older build didn't this
> conversion.)

OK, I'll remove the regression keyword and I think it's ok if we don't get a regression window here. I've also tried to clarify the summary a bit.
Flags: needinfo?(subs)
Priority: P1 → P3
Summary: innerText regression: reading/writing new lines is no longer correct/consistent → innerText should ignore "invisible" break when serializing HTML fragment
You need to log in before you can comment on or make changes to this bug.