Skip to content

fix: update document APIs to be readonly#26

Merged
alan-agius4 merged 1 commit intoangular:mainfrom
dgp1130:readonly
Mar 13, 2026
Merged

fix: update document APIs to be readonly#26
alan-agius4 merged 1 commit intoangular:mainfrom
dgp1130:readonly

Conversation

@dgp1130
Copy link

@dgp1130 dgp1130 commented Mar 12, 2026

By spec, these APIs are readonly, but do not error when mutated, they just have no effect. APIs affected:

This helps prevent malicious data from sneaking into these attributes after construction.

Alternative solution to: #23

/cc @securityMB

By spec, these APIs are `readonly`, but do not error when mutated, they just have no effect. APIs affected:
* [`Attr.prototype.localName`](https://developer.mozilla.org/en-US/docs/Web/API/Attr/localName)
* [`Attr.prototype.prefix`](https://developer.mozilla.org/en-US/docs/Web/API/Attr/prefix)
* [`Element.prototype.localName`](https://developer.mozilla.org/en-US/docs/Web/API/Element/localName)
* [`Element.prototype.prefix`](https://developer.mozilla.org/en-US/docs/Web/API/Element/prefix)
* [`DocumentType.prototype.name`](https://developer.mozilla.org/en-US/docs/Web/API/DocumentType/name)
* [`ProcessingInstruction.prototype.target`](https://developer.mozilla.org/en-US/docs/Web/API/ProcessingInstruction/target)

This helps prevent malicious data from sneaking into these attributes after construction.
@dgp1130 dgp1130 requested a review from alan-agius4 March 12, 2026 22:32
@dgp1130 dgp1130 added the bug Something isn't working label Mar 12, 2026
Copy link

@AndrewKushnir AndrewKushnir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks @dgp1130 👍

@alan-agius4 alan-agius4 merged commit 24d1e0d into angular:main Mar 13, 2026
4 checks passed
@dgp1130 dgp1130 deleted the readonly branch March 13, 2026 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants