mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
support slot attribute on DOM elements for V1 shadowDom named slots p… (#8061)
* support slot attribute on DOM elements for V1 shadowDom named slots projection Closes #7784 * fix(test): fix lint errors
This commit is contained in:
committed by
Brandon Dail
parent
c1cca0c7d8
commit
346d50e2ba
@@ -139,6 +139,8 @@ var HTMLDOMPropertyConfig = {
|
||||
shape: 0,
|
||||
size: HAS_POSITIVE_NUMERIC_VALUE,
|
||||
sizes: 0,
|
||||
// support for projecting regular DOM Elements via V1 named slots ( shadow dom )
|
||||
slot: 0,
|
||||
span: HAS_POSITIVE_NUMERIC_VALUE,
|
||||
spellCheck: 0,
|
||||
src: 0,
|
||||
|
||||
@@ -245,6 +245,24 @@ describe('ReactDOMComponent', () => {
|
||||
expect(stubStyle.display).toEqual('');
|
||||
});
|
||||
|
||||
it('should allow named slot projection on both web components and regular DOM elements', () => {
|
||||
var container = document.createElement('div');
|
||||
|
||||
ReactDOM.render(
|
||||
<my-component>
|
||||
<my-second-component slot="first"></my-second-component>
|
||||
<button slot="second">Hello</button>
|
||||
</my-component>,
|
||||
container
|
||||
);
|
||||
|
||||
var lightDOM = container.firstChild.childNodes;
|
||||
|
||||
expect(lightDOM[0].getAttribute('slot')).toBe('first');
|
||||
expect(lightDOM[1].getAttribute('slot')).toBe('second');
|
||||
|
||||
} );
|
||||
|
||||
it('should skip reserved props on web components', () => {
|
||||
var container = document.createElement('div');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user