2 ms·
I don't like this. This could be implemented as a JS library. I believe browsers should provide the minimal API so that they are smaller and easier to create. A
by codedokode 1y ago
I don't like this. This could be implemented as a JS library. I believe browsers should provide the minimal API so that they are smaller and easier to create. As for safe alternative to innerHTML, it is called innerText.
- csmantle 1y agoI think innerText and setHTML() have different purposes. The former inserts the whole string as a text leaf, while the latter tries to preserve structures that are meaningful in context. --- Libraries can surely do the same job, but then the exact behavior would vary among a sea of those libs. Having specs defined [0] for such an interface would hopefully iron out much of these variations, as well as enabling some performance gains. [0]: https://wicg.github.io/sanitizer-api/#dom-element-sethtml https://wicg.github.io/sanitizer-api/#dom-element-sethtml
- codedokode 1y agoAnd if you need something that is not in a spec, you have to use a library anyway. Also the point was that browser should be as simple as possible and not like a whole new OS.
- codezero 1y agoinnerText has wildly inconsistent implementations across browsers.
- petralithic 1y ago> I believe browsers should provide the minimal API so that they are smaller and easier to create. That ship has long since sailed. Browsers are so complex that it takes quite some effort to support the various levels of 9s of the percentage of compatibility with standards, not to mention the browser makers themselves define many of the standards.
- deleted 1y ago[deleted]