-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
innerText issues #1679
Comments
Which of these do you think we'd need to resolve before merging #1678? In my opinion the setter issue should block merging but the rest are OK-ish... |
rocallahan/innerText-spec#5 also seems kind of bad |
Just return
That adds complexity and it's hard to imagine it's required for Web compat.
Ditto.
Yeah that should be fixed, but you could fix it after merging. |
Fixed the setter in 0783a61 |
Found a new issue today (updated OP)
|
From https://rocallahan.github.io/innerText-spec/ with the following normative changes: * Defined behavior for non-CSS UAs. * The setter is better defined. * Added [CEReactions, TreatNullAs=EmptyString] to the IDL. Fixes #465. Remaining issues: #1679
|
The rendering section in HTML has this
Is this something that people want to do in |
I'd like to help clean up some of the aforementioned comments on how the algorithm performs recursion if that'd be helpful, as I think it is a little odd. Personally I prefer a recursive definition to an iterative one in this case given it is a classic DFS, but here are some things I noticed: 1.) Cleaning up recursion Step 2 mentions much of what substep 1 mentions. It like having the following algorithm: function topProcedure(element) {
let list = [];
for (let i = 0; i < element.children.length; ++i) {
list += recursiveProcedure(element.children[i]);
}
}
function recursiveProcedure(childElement) {
let list = [];
for (let i = 0; i < childElement.children.length; ++i) {
list += recursiveProcedure(childElement.children[i]);
}
// do some parsing/concat with `list`
} ...we unnecessarily repeat ourselves in this when we could just call 2.) Element ( Step 2 mentions "applying the following recursive procedure to each child node 3.) This one gets me. Is there a reason why the two sections in fiddle should have different results? I can't really think of one but it is entirely possible I'm just missing something. |
So @zcorpan is our innerText expert but he's out for a while. Let me see if I can answer these satisfactorily... Overall it would indeed be great to clean up the recursion to make it more explicit. "Applying the following recursive procedure" is hard to understand; I think we all knew that. So cleaning it up to be more like normal programming would make a lot of sense.
|
Cool I can submit a PR!
Perfect that's what I wasn't sure about. I guess I was referring to how in step 2 we apply the procedure to "each child node
IIRC I believe Safari matches Chrome + Firefox FWIW. Cool thanks! |
Are Chrome, Firefox, and Safari in violation of the spec at this time? Consider the following HTML: <p>
<span style="display: none">Does this text count as innerText?</span>
</p> From my understanding the spec indicates that the text "Does this text...." should be returned from Explanation: When calling When we're unwinding upward we hit the stack frame that was passed the Edit@domenic I assume by
You didn't mean they give different values from what the spec says they should (aka they're in violation); but if that's what you meant then sorry this is duplicate info. ...and if they are indeed in violation I assume we should change the spec right? |
No, we don't, because the Text node has no CSS boxes so we bail out at step 3 before reaching step 4. |
|
@rocallahan Hm does that mean we'd never meet the condition for substep 4 then? Because if we did, that means we're operating on a Text node, and if we're operating on a Text node we'd always bail out early (substep 3) no? |
A |
From https://rocallahan.github.io/innerText-spec/ with the following normative changes: * Defined behavior for non-CSS UAs. * The setter is better defined. * Added [CEReactions, TreatNullAs=EmptyString] to the IDL. Fixes whatwg#465. Remaining issues: whatwg#1679
When working on #1678 I found the following issues.
cc @rocallahan
Getter
What should non-CSS UAs do? (45253f9)
Is "content order" for CSS boxes defined? (Step 2.5.) (Issue moved to [css-text] Define "content order" for innerText w3c/csswg-drafts#421 )
The
rp
check only works for direct children ofrp
, not descendants (e.g.<ruby><rp><span>(</span></rp>...
).Do we want that to work? Or change the content model or
rp
to "text"?(Change <rp>'s content model to Text #1690)
Issue inline in the spec:
@annevk said:
@zcorpan said:
2202c6c
Setter
The setter needs to be better defined, in terms of DOM concepts so mutation observers are invoked correctly etc. (0783a61)
innerText = null;
WebKit/Chromium "", Gecko/IE "null". (618de84 , Test innerText = ""/null/undefined web-platform-tests/wpt#3482)Chromium throws for
<br>.innerText = "x"
etc, Gecko does not.https://cs.chromium.org/chromium/src/third_party/WebKit/Source/core/html/HTMLElement.cpp?sq=package:chromium&dr=CSs&rcl=1471276009&l=140
https://cs.chromium.org/chromium/src/third_party/WebKit/Source/core/html/HTMLElement.cpp?sq=package:chromium&dr=CSs&rcl=1471276009&l=454
(Test that setting innerText on <br> etc doesn't throw web-platform-tests/wpt#3491)
Only update existing text node's data if element has just 1 text node?
https://cs.chromium.org/chromium/src/third_party/WebKit/Source/core/editing/serializers/Serialization.cpp?sq=package:chromium&dr=CSs&rcl=1471276009&l=640
(innerText setter should replace existing text node web-platform-tests/wpt#3493)
If the assigned value starts with a newline, WebKit/Chromium insert an empty text node, Gecko/IE don't. (Current spec matches Gecko/IE.)
(innerText setter should not result in empty text nodes web-platform-tests/wpt#3492)
(Filed chromium bug 639064, webkit bug 160971, edge bug 8536472 for some of the above bullet points)
Other known issues
The text was updated successfully, but these errors were encountered: