豆豆友情提示:这是一个非官方 GitHub 代理镜像,主要用于网络测试或访问加速。请勿在此进行登录、注册或处理任何敏感信息。进行这些操作请务必访问官方网站 github.com。 Raw 内容也通过此代理提供。
Skip to content

Add credentialless as a recognized boolean attribute for iframes#36148

Merged
hoxyq merged 2 commits intomainfrom
feat/add-credentialless-iframe-attribute
Apr 20, 2026
Merged

Add credentialless as a recognized boolean attribute for iframes#36148
hoxyq merged 2 commits intomainfrom
feat/add-credentialless-iframe-attribute

Conversation

@vmx906
Copy link
Copy Markdown
Contributor

@vmx906 vmx906 commented Mar 26, 2026

Summary

The credentialless attribute is a boolean HTML attribute for <iframe> elements that loads the iframe in a new, ephemeral context without access to the parent's credentials (cookies, client certificates, etc.). This change adds it to all boolean attribute switch/case lists in React DOM so it is properly handled as a boolean (set when true, removed when false) rather than being treated as an unknown string attribute.

Per the Anonymous iframe spec (WICG):

The credentialless attribute enables loading documents hosted by the iframe with a new and ephemeral storage partition. It is a boolean value. The default is false.

partial interface HTMLIFrameElement {
  attribute boolean credentialless; 
};

Changes:

  • ReactDOMComponent.js: Added to both setProp and diffHydratedGenericElement
  • ReactFizzConfigDOM.js: Added to pushAttribute for server-side rendering
  • ReactDOMUnknownPropertyHook.js: Added to both validation switch/case lists

Test plan

  • Added unit test in DOMPropertyOperations-test.js verifying credentialless={true} sets the attribute to '' and credentialless={false} removes it
  • All tests pass in source and www channels (590 tests each)
  • Flow type checking passes (dom-node renderer)
  • Prettier and lint pass

## Summary

The `credentialless` attribute is a boolean HTML attribute for `<iframe>` elements
that loads the iframe in a new, ephemeral context without access to the parent's
credentials (cookies, client certificates, etc.). This change adds it to all
boolean attribute switch/case lists in React DOM so it is properly handled as a
boolean (set when true, removed when false) rather than being treated as an
unknown string attribute.

Changes:
- ReactDOMComponent.js: Added to both `setProp` and `diffHydratedGenericElement`
- ReactFizzConfigDOM.js: Added to `pushAttribute` for server-side rendering
- ReactDOMUnknownPropertyHook.js: Added to both validation switch/case lists

## Test plan

- Added unit test in DOMPropertyOperations-test.js verifying `credentialless={true}`
  sets the attribute to `''` and `credentialless={false}` removes it
- Added server rendering tests in ReactDOMServerIntegrationAttributes-test.js for
  both true and false values
- All tests pass in source and www channels (590 tests each)
- Flow type checking passes (dom-node renderer)
- Prettier and lint pass
@meta-cla meta-cla bot added the CLA Signed label Mar 26, 2026
@react-sizebot
Copy link
Copy Markdown

react-sizebot commented Mar 26, 2026

Comparing: 3cb2c42...8709472

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable/react-dom/cjs/react-dom.production.js = 6.84 kB 6.84 kB +0.11% 1.88 kB 1.88 kB
oss-stable/react-dom/cjs/react-dom-client.production.js = 612.88 kB 612.90 kB +0.01% 108.30 kB 108.31 kB
oss-experimental/react-dom/cjs/react-dom.production.js = 6.84 kB 6.84 kB +0.05% 1.88 kB 1.88 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js = 678.81 kB 678.84 kB = 119.26 kB 119.27 kB
facebook-www/ReactDOM-prod.classic.js = 698.20 kB 698.23 kB = 122.65 kB 122.66 kB
facebook-www/ReactDOM-prod.modern.js = 688.52 kB 688.54 kB +0.01% 121.03 kB 121.04 kB

Significant size changes

Includes any change greater than 0.2%:

(No significant changes)

Generated by 🚫 dangerJS against 8709472

@vmx906 vmx906 requested a review from rickhanlonii March 27, 2026 10:50
mahdirajaee

This comment was marked as spam.

await act(() => {
root.render(<iframe credentialless={true} />);
});
expect(container.firstChild.getAttribute('credentialless')).toBe('');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@vmx906 I am a bit confused, should this be expect(container.firstChild.getAttribute('credentialless')).toBe('true'); ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@hoxyq I believe react set this to empty string when the prop is bool, see [1]

if (value && typeof value !== 'function' && typeof value !== 'symbol') {
        domElement.setAttribute(key, '');
      }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@vmx906 Oh, I see, thanks! We use the presence of the attribute as a source of truth for boolean attributes.

case 'seamless':
case 'itemScope': {
if (value && typeof value !== 'function' && typeof value !== 'symbol') {
domElement.setAttribute(key, '');
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

[1]

await act(() => {
root.render(<iframe credentialless={true} />);
});
expect(container.firstChild.getAttribute('credentialless')).toBe('');
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@hoxyq I believe react set this to empty string when the prop is bool, see [1]

if (value && typeof value !== 'function' && typeof value !== 'symbol') {
        domElement.setAttribute(key, '');
      }

Comment on lines 2852 to 2853
case 'controls':
case 'default':
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@vmx906 I think you need to add credentialless here as well.

Can you also add a few test cases to ReactDOMServerIntegrationAttributes-test.js, similarly to what you did in DOMPropertyOperations-test.js?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch! Updated this missing path and added test

@hoxyq hoxyq merged commit 306a01b into main Apr 20, 2026
239 checks passed
@hoxyq hoxyq deleted the feat/add-credentialless-iframe-attribute branch April 20, 2026 17:37
github-actions bot pushed a commit that referenced this pull request Apr 20, 2026
)

## Summary

The `credentialless` attribute is a boolean HTML attribute for
`<iframe>` elements that loads the iframe in a new, ephemeral context
without access to the parent's credentials (cookies, client
certificates, etc.). This change adds it to all boolean attribute
switch/case lists in React DOM so it is properly handled as a boolean
(set when true, removed when false) rather than being treated as an
unknown string attribute.

Per the [Anonymous iframe spec
(WICG)](https://wicg.github.io/anonymous-iframe/):

> The credentialless attribute enables loading documents hosted by the
iframe with a new and ephemeral storage partition. It is a boolean
value. The default is false.

```
partial interface HTMLIFrameElement {
  attribute boolean credentialless;
};
```

Changes:
- ReactDOMComponent.js: Added to both `setProp` and
`diffHydratedGenericElement`
- ReactFizzConfigDOM.js: Added to `pushAttribute` for server-side
rendering
- ReactDOMUnknownPropertyHook.js: Added to both validation switch/case
lists

## Test plan

- Added unit test in DOMPropertyOperations-test.js verifying
`credentialless={true}` sets the attribute to `''` and
`credentialless={false}` removes it
- All tests pass in source and www channels (590 tests each)
- Flow type checking passes (dom-node renderer)
- Prettier and lint pass

DiffTrain build for [306a01b](306a01b)
github-actions bot pushed a commit that referenced this pull request Apr 20, 2026
)

## Summary

The `credentialless` attribute is a boolean HTML attribute for
`<iframe>` elements that loads the iframe in a new, ephemeral context
without access to the parent's credentials (cookies, client
certificates, etc.). This change adds it to all boolean attribute
switch/case lists in React DOM so it is properly handled as a boolean
(set when true, removed when false) rather than being treated as an
unknown string attribute.

Per the [Anonymous iframe spec
(WICG)](https://wicg.github.io/anonymous-iframe/):

> The credentialless attribute enables loading documents hosted by the
iframe with a new and ephemeral storage partition. It is a boolean
value. The default is false.

```
partial interface HTMLIFrameElement {
  attribute boolean credentialless;
};
```

Changes:
- ReactDOMComponent.js: Added to both `setProp` and
`diffHydratedGenericElement`
- ReactFizzConfigDOM.js: Added to `pushAttribute` for server-side
rendering
- ReactDOMUnknownPropertyHook.js: Added to both validation switch/case
lists

## Test plan

- Added unit test in DOMPropertyOperations-test.js verifying
`credentialless={true}` sets the attribute to `''` and
`credentialless={false}` removes it
- All tests pass in source and www channels (590 tests each)
- Flow type checking passes (dom-node renderer)
- Prettier and lint pass

DiffTrain build for [306a01b](306a01b)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants