|
1 | 1 | import { h, cloneElement, render, hydrate, Fragment } from 'preact'; |
2 | 2 |
|
3 | 3 | /** |
4 | | - * @typedef {import('./index.d.ts').PreactCustomElement} PreactCustomElement |
| 4 | + * @typedef {import('./internal.d.ts').PreactCustomElement} PreactCustomElement |
5 | 5 | */ |
6 | 6 |
|
7 | 7 | /** |
8 | | - * @type {import('./index.d.ts').default} |
| 8 | + * @type {import('./index.d.ts')} |
9 | 9 | */ |
10 | 10 | export default function register(Component, tagName, propNames, options) { |
11 | 11 | function PreactElement() { |
12 | 12 | const inst = /** @type {PreactCustomElement} */ ( |
13 | 13 | Reflect.construct(HTMLElement, [], PreactElement) |
14 | 14 | ); |
15 | 15 | inst._vdomComponent = Component; |
16 | | - inst._root = |
17 | | - options && options.shadow |
18 | | - ? inst.attachShadow({ mode: options.mode || 'open' }) |
19 | | - : inst; |
20 | 16 |
|
21 | | - if (options && options.adoptedStyleSheets) { |
22 | | - inst._root.adoptedStyleSheets = options.adoptedStyleSheets; |
| 17 | + if (options && options.shadow) { |
| 18 | + inst._root = inst.attachShadow({ mode: options.mode || 'open' }); |
| 19 | + |
| 20 | + if (options.adoptedStyleSheets) { |
| 21 | + inst._root.adoptedStyleSheets = options.adoptedStyleSheets; |
| 22 | + } |
| 23 | + } else { |
| 24 | + inst._root = inst; |
23 | 25 | } |
24 | 26 |
|
25 | 27 | return inst; |
@@ -49,9 +51,7 @@ export default function register(Component, tagName, propNames, options) { |
49 | 51 | propNames.forEach((name) => { |
50 | 52 | Object.defineProperty(PreactElement.prototype, name, { |
51 | 53 | get() { |
52 | | - return this._vdom |
53 | | - ? this._vdom.props[name] |
54 | | - : this._props[name]; |
| 54 | + return this._vdom ? this._vdom.props[name] : this._props[name]; |
55 | 55 | }, |
56 | 56 | set(v) { |
57 | 57 | if (this._vdom) { |
|
0 commit comments