Skip to content

Remove custom element state when is attribute is blocked#396

Draft
evilpie wants to merge 1 commit into
WICG:mainfrom
evilpie:is-attribute
Draft

Remove custom element state when is attribute is blocked#396
evilpie wants to merge 1 commit into
WICG:mainfrom
evilpie:is-attribute

Conversation

@evilpie
Copy link
Copy Markdown
Collaborator

@evilpie evilpie commented Apr 16, 2026

This depends on changes in #385 that haven't happened yet.

I am not really certain if there isn't some other data structure that we need to patch for this. Presumably this would be easier to specify when we do streaming parsing.

Fixes #387.


Preview | Diff

Comment thread index.bs
1. Set |elementWithLocalAttributes| to
|configuration|["{{SanitizerConfig/elements}}"][|elementName|].
1. If |child|'s [=is value=] is not `null`:
1. Set |isAttribute| to «[ "`name`" → "`is`", "`namespace`" → null ]».
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Let isAttribute be?

Comment thread index.bs
1. If |child|'s [=is value=] is not `null`:
1. Set |isAttribute| to «[ "`name`" → "`is`", "`namespace`" → null ]».
1. If [=is attribute allowed=] for |isAttribute| given |configuration|,
|child| is [=/blocked=]:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This reads weird. Should it be "given configuration and child"?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Ah yeah, I copy pasted that from #385 and removed the handleJavascriptNavigationUrls parameter carelessly.

@otherdaniel
Copy link
Copy Markdown
Collaborator

Looks good editorially, but I wonder whether this would execute the custom element constructor during parsing?

As I understand this, this would create the custom element, and then later remove it again. If so, I'd expect this to execute the custom element's constructor, and thus bypass sanitization in a sense.

@evilpie
Copy link
Copy Markdown
Collaborator Author

evilpie commented Apr 29, 2026

Looks good editorially, but I wonder whether this would execute the custom element constructor during parsing?

As I understand this, this would create the custom element, and then later remove it again. If so, I'd expect this to execute the custom element's constructor, and thus bypass sanitization in a sense.

No it doesn't AFAIK. The custom constructor (if not removed) is only invoked when inserting. IIRC because the custom elements registry is null for those documents we use for parsing?

You can actually try this out with div.setHTML('<div is="custom-div"></div>') in Firefox Nightly.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The is non-attribute allows custom elements to sneak in

3 participants