Skip to content

Define maximum length and handling of CharacterData nodes #1351

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

Open
annevk opened this issue Jan 24, 2025 · 2 comments
Open

Define maximum length and handling of CharacterData nodes #1351

annevk opened this issue Jan 24, 2025 · 2 comments

Comments

@annevk
Copy link
Member

annevk commented Jan 24, 2025

Currently we pretend that all CharacterData nodes (Text, CDATASection, ProcessingInstruction, and Comment) can have infinite length. In practice however it seems the upper limit has to be JavaScript's String's maximum length, which is 253 − 1.

Should we standardize on that and attempt to deal with the consequences for wholeText, normalize(), etc?

cc @rniwa @smaug---- @mfreed7

@smaug----
Copy link
Collaborator

Feels a bit overkill. I'd assume the platform has plenty of places where string length may get too large.
documentElement.textContent for example. Even though that is not modifying the DOM itself, what should happen on the caller side if there is OOM or otherwise too large string? (I think Gecko will throw some out-of-memory exception in that case)

Infra talks about something related https://infra.spec.whatwg.org/#algorithm-limits

@annevk
Copy link
Member Author

annevk commented Apr 11, 2025

I think Infra's carveout is less applicable here as String has a well-defined length. And CharacterData cannot exceed that length. So here we can in fact define reasonable behavior in all the edge cases (such as throwing or not normalizing).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants