-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Spec HTMLElement.outerText #668
Comments
Is this necessary for compat? |
Paging @miketaylr. |
So, any interest in this now that innerText got merged (#1678)? @miketaylr ? |
This is necessary for compat. All but Gecko supported this property for ages. |
Do you have data to back that up? Gecko does not seem to ever have hit compat issues because of this. |
It seems to me it is a shorter path to interop if Gecko adds Looking through https://github.com/search?l=JavaScript&q=outertext+gecko&ref=searchresults&type=Code&utf8=✓ I mostly see polyfills of @Ms2ger do you object to adding this to Gecko? |
I would prefer not to add, but I have no decision power for Gecko :) |
@smaug---- WDYT? |
Is it? Do we know what outerText should do? If it is just a variant of the same algorithm as innerText, then adding it sounds ok, but I don't know how it has been implemented. |
The outerText getter is an alias of innerText in Blink, but the setters actually don't share much code. The outerText setter looks a lot like outerHTML's though. |
I wonder what the usage rates of the getter vs. setter are. Although even if the setter is low, I can't imagine 3 browsers will want to remove it. |
If usage were minuscule and removing it would simplify matters it's not unthinkable, but I wonder if it would simplify anything. @zcorpan, what do you think this would look like in spec terms? |
The getter would just be an alias of innerText. The setter I thought would be like outerHTML's setter but instead of parsing HTML you construct a DocumentFragment using the same logic as in the innerText setter. It turns out there are a few differences between Chromium and Edge 13 for outerText, and for outerHTML there's a difference between Edge 13 and IE 11.
The spec for outerHTML does not say to merge text nodes. I don't see much point in doing that, and if Edge has already changed outerHTML to not do it, maybe could also change outerText to stop merging text nodes? Tests |
(whoops, these pings got lost in my inbox... 😞)
It would be cool to see actual broken pages. Looking at https://gist.github.com/zcorpan/5f3dc4c37367b8551e9295892b0aeb66 from @zcorpan I see a ton of (minified) TinyMCE usage. But that function is only used in an IE codepath: function toStringIE() {
return dom.create('body', null, cloneContents()).outerText;
} Makes me wonder about the other results. All the dojo usage is in an IE codepath as well:
|
(This should be feasible after #465 is resolved.)
Basic info: https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/outerText
HTMLElement.outerText
appears to be supported in all major browsers except Firefox, but currently doesn't seem to be spec'd anywhere.Its getter seems to return the same value as
innerText
.Its setter removes the element and replaces it with the given raw text string (no HTML parsing).
The text was updated successfully, but these errors were encountered: