isomorfeus-preact 10.6.14 → 10.6.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/isomorfeus-preact.rb +3 -3
- data/lib/isomorfeus_preact/lucid_component/api.rb +1 -1
- data/lib/isomorfeus_preact/lucid_component/initializer.rb +2 -2
- data/lib/isomorfeus_preact/lucid_func/initializer.rb +1 -1
- data/lib/isomorfeus_preact/preact/function_component/initializer.rb +1 -1
- data/lib/preact/component/api.rb +1 -1
- data/lib/preact/component/callbacks.rb +6 -6
- data/lib/preact/component/initializer.rb +2 -2
- data/lib/preact/component/native_component_constructor.rb +1 -1
- data/lib/preact/props.rb +51 -0
- data/lib/preact/state.rb +67 -0
- data/lib/preact/version.rb +1 -1
- data/lib/preact.rb +2 -2
- data/node_modules/.package-lock.json +3 -3
- data/node_modules/preact/LICENSE +21 -21
- data/node_modules/preact/README.md +187 -187
- data/node_modules/preact/compat/dist/compat.js +1 -1
- data/node_modules/preact/compat/dist/compat.js.map +1 -1
- data/node_modules/preact/compat/dist/compat.mjs +1 -1
- data/node_modules/preact/compat/dist/compat.module.js +1 -1
- data/node_modules/preact/compat/dist/compat.module.js.map +1 -1
- data/node_modules/preact/compat/dist/compat.umd.js +1 -1
- data/node_modules/preact/compat/dist/compat.umd.js.map +1 -1
- data/node_modules/preact/compat/jsx-dev-runtime.js +1 -1
- data/node_modules/preact/compat/jsx-dev-runtime.mjs +1 -1
- data/node_modules/preact/compat/jsx-runtime.js +1 -1
- data/node_modules/preact/compat/jsx-runtime.mjs +1 -1
- data/node_modules/preact/compat/package.json +19 -19
- data/node_modules/preact/compat/scheduler.js +15 -15
- data/node_modules/preact/compat/scheduler.mjs +23 -23
- data/node_modules/preact/compat/server.js +15 -15
- data/node_modules/preact/compat/server.mjs +4 -4
- data/node_modules/preact/compat/src/Children.js +21 -21
- data/node_modules/preact/compat/src/PureComponent.js +15 -15
- data/node_modules/preact/compat/src/forwardRef.js +51 -51
- data/node_modules/preact/compat/src/index.d.ts +141 -141
- data/node_modules/preact/compat/src/index.js +187 -187
- data/node_modules/preact/compat/src/internal.d.ts +47 -47
- data/node_modules/preact/compat/src/memo.js +34 -34
- data/node_modules/preact/compat/src/portals.js +80 -80
- data/node_modules/preact/compat/src/render.js +229 -230
- data/node_modules/preact/compat/src/suspense-list.d.ts +14 -14
- data/node_modules/preact/compat/src/suspense-list.js +126 -126
- data/node_modules/preact/compat/src/suspense.d.ts +15 -15
- data/node_modules/preact/compat/src/suspense.js +270 -270
- data/node_modules/preact/compat/src/util.js +28 -28
- data/node_modules/preact/compat/test-utils.js +1 -1
- data/node_modules/preact/debug/dist/debug.js.map +1 -1
- data/node_modules/preact/debug/dist/debug.module.js.map +1 -1
- data/node_modules/preact/debug/dist/debug.umd.js.map +1 -1
- data/node_modules/preact/debug/package.json +18 -18
- data/node_modules/preact/debug/src/check-props.js +54 -54
- data/node_modules/preact/debug/src/component-stack.js +146 -146
- data/node_modules/preact/debug/src/constants.js +3 -3
- data/node_modules/preact/debug/src/debug.js +442 -442
- data/node_modules/preact/debug/src/index.js +6 -6
- data/node_modules/preact/debug/src/internal.d.ts +82 -82
- data/node_modules/preact/debug/src/util.js +11 -11
- data/node_modules/preact/devtools/dist/devtools.js +1 -1
- data/node_modules/preact/devtools/dist/devtools.js.map +1 -1
- data/node_modules/preact/devtools/dist/devtools.mjs +1 -1
- data/node_modules/preact/devtools/dist/devtools.module.js +1 -1
- data/node_modules/preact/devtools/dist/devtools.module.js.map +1 -1
- data/node_modules/preact/devtools/dist/devtools.umd.js +1 -1
- data/node_modules/preact/devtools/dist/devtools.umd.js.map +1 -1
- data/node_modules/preact/devtools/package.json +16 -16
- data/node_modules/preact/devtools/src/devtools.js +10 -10
- data/node_modules/preact/devtools/src/index.d.ts +8 -8
- data/node_modules/preact/devtools/src/index.js +15 -15
- data/node_modules/preact/dist/preact.js.map +1 -1
- data/node_modules/preact/dist/preact.min.js.map +1 -1
- data/node_modules/preact/dist/preact.module.js.map +1 -1
- data/node_modules/preact/dist/preact.umd.js.map +1 -1
- data/node_modules/preact/hooks/dist/hooks.js +1 -1
- data/node_modules/preact/hooks/dist/hooks.js.map +1 -1
- data/node_modules/preact/hooks/dist/hooks.mjs +1 -1
- data/node_modules/preact/hooks/dist/hooks.module.js +1 -1
- data/node_modules/preact/hooks/dist/hooks.module.js.map +1 -1
- data/node_modules/preact/hooks/dist/hooks.umd.js +1 -1
- data/node_modules/preact/hooks/dist/hooks.umd.js.map +1 -1
- data/node_modules/preact/hooks/package.json +26 -26
- data/node_modules/preact/hooks/src/index.d.ts +139 -139
- data/node_modules/preact/hooks/src/index.js +386 -388
- data/node_modules/preact/hooks/src/internal.d.ts +75 -75
- data/node_modules/preact/jsx-runtime/dist/jsxRuntime.js.map +1 -1
- data/node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js.map +1 -1
- data/node_modules/preact/jsx-runtime/dist/jsxRuntime.umd.js.map +1 -1
- data/node_modules/preact/jsx-runtime/package.json +19 -19
- data/node_modules/preact/jsx-runtime/src/index.d.ts +50 -50
- data/node_modules/preact/jsx-runtime/src/index.js +77 -77
- data/node_modules/preact/package.json +291 -287
- data/node_modules/preact/src/cjs.js +3 -3
- data/node_modules/preact/src/clone-element.js +34 -34
- data/node_modules/preact/src/component.js +225 -225
- data/node_modules/preact/src/constants.js +3 -3
- data/node_modules/preact/src/create-context.js +68 -68
- data/node_modules/preact/src/create-element.js +98 -98
- data/node_modules/preact/src/diff/catch-error.js +38 -38
- data/node_modules/preact/src/diff/children.js +335 -335
- data/node_modules/preact/src/diff/index.js +516 -516
- data/node_modules/preact/src/diff/props.js +158 -158
- data/node_modules/preact/src/index.d.ts +310 -310
- data/node_modules/preact/src/index.js +13 -13
- data/node_modules/preact/src/internal.d.ts +146 -146
- data/node_modules/preact/src/jsx.d.ts +1005 -1005
- data/node_modules/preact/src/options.js +16 -16
- data/node_modules/preact/src/render.js +75 -75
- data/node_modules/preact/src/util.js +27 -27
- data/node_modules/preact/test-utils/dist/testUtils.js.map +1 -1
- data/node_modules/preact/test-utils/dist/testUtils.module.js.map +1 -1
- data/node_modules/preact/test-utils/dist/testUtils.umd.js.map +1 -1
- data/node_modules/preact/test-utils/package.json +19 -19
- data/node_modules/preact/test-utils/src/index.d.ts +3 -3
- data/node_modules/preact/test-utils/src/index.js +117 -117
- data/package.json +1 -1
- metadata +4 -4
- data/lib/preact/component/props.rb +0 -55
- data/lib/preact/component/state.rb +0 -58
@@ -1,80 +1,80 @@
|
|
1
|
-
import { createElement, render } from 'preact';
|
2
|
-
|
3
|
-
/**
|
4
|
-
* @param {import('../../src/index').RenderableProps<{ context: any }>} props
|
5
|
-
*/
|
6
|
-
function ContextProvider(props) {
|
7
|
-
this.getChildContext = () => props.context;
|
8
|
-
return props.children;
|
9
|
-
}
|
10
|
-
|
11
|
-
/**
|
12
|
-
* Portal component
|
13
|
-
* @this {import('./internal').Component}
|
14
|
-
* @param {object | null | undefined} props
|
15
|
-
*
|
16
|
-
* TODO: use createRoot() instead of fake root
|
17
|
-
*/
|
18
|
-
function Portal(props) {
|
19
|
-
const _this = this;
|
20
|
-
let container = props._container;
|
21
|
-
|
22
|
-
_this.componentWillUnmount = function() {
|
23
|
-
render(null, _this._temp);
|
24
|
-
_this._temp = null;
|
25
|
-
_this._container = null;
|
26
|
-
};
|
27
|
-
|
28
|
-
// When we change container we should clear our old container and
|
29
|
-
// indicate a new mount.
|
30
|
-
if (_this._container && _this._container !== container) {
|
31
|
-
_this.componentWillUnmount();
|
32
|
-
}
|
33
|
-
|
34
|
-
// When props.vnode is undefined/false/null we are dealing with some kind of
|
35
|
-
// conditional vnode. This should not trigger a render.
|
36
|
-
if (props._vnode) {
|
37
|
-
if (!_this._temp) {
|
38
|
-
_this._container = container;
|
39
|
-
|
40
|
-
// Create a fake DOM parent node that manages a subset of `container`'s children:
|
41
|
-
_this._temp = {
|
42
|
-
nodeType: 1,
|
43
|
-
parentNode: container,
|
44
|
-
childNodes: [],
|
45
|
-
appendChild(child) {
|
46
|
-
this.childNodes.push(child);
|
47
|
-
_this._container.appendChild(child);
|
48
|
-
},
|
49
|
-
insertBefore(child, before) {
|
50
|
-
this.childNodes.push(child);
|
51
|
-
_this._container.appendChild(child);
|
52
|
-
},
|
53
|
-
removeChild(child) {
|
54
|
-
this.childNodes.splice(this.childNodes.indexOf(child) >>> 1, 1);
|
55
|
-
_this._container.removeChild(child);
|
56
|
-
}
|
57
|
-
};
|
58
|
-
}
|
59
|
-
|
60
|
-
// Render our wrapping element into temp.
|
61
|
-
render(
|
62
|
-
createElement(ContextProvider, { context: _this.context }, props._vnode),
|
63
|
-
_this._temp
|
64
|
-
);
|
65
|
-
}
|
66
|
-
// When we come from a conditional render, on a mounted
|
67
|
-
// portal we should clear the DOM.
|
68
|
-
else if (_this._temp) {
|
69
|
-
_this.componentWillUnmount();
|
70
|
-
}
|
71
|
-
}
|
72
|
-
|
73
|
-
/**
|
74
|
-
* Create a `Portal` to continue rendering the vnode tree at a different DOM node
|
75
|
-
* @param {import('./internal').VNode} vnode The vnode to render
|
76
|
-
* @param {import('./internal').PreactElement} container The DOM node to continue rendering in to.
|
77
|
-
*/
|
78
|
-
export function createPortal(vnode, container) {
|
79
|
-
return createElement(Portal, { _vnode: vnode, _container: container });
|
80
|
-
}
|
1
|
+
import { createElement, render } from 'preact';
|
2
|
+
|
3
|
+
/**
|
4
|
+
* @param {import('../../src/index').RenderableProps<{ context: any }>} props
|
5
|
+
*/
|
6
|
+
function ContextProvider(props) {
|
7
|
+
this.getChildContext = () => props.context;
|
8
|
+
return props.children;
|
9
|
+
}
|
10
|
+
|
11
|
+
/**
|
12
|
+
* Portal component
|
13
|
+
* @this {import('./internal').Component}
|
14
|
+
* @param {object | null | undefined} props
|
15
|
+
*
|
16
|
+
* TODO: use createRoot() instead of fake root
|
17
|
+
*/
|
18
|
+
function Portal(props) {
|
19
|
+
const _this = this;
|
20
|
+
let container = props._container;
|
21
|
+
|
22
|
+
_this.componentWillUnmount = function() {
|
23
|
+
render(null, _this._temp);
|
24
|
+
_this._temp = null;
|
25
|
+
_this._container = null;
|
26
|
+
};
|
27
|
+
|
28
|
+
// When we change container we should clear our old container and
|
29
|
+
// indicate a new mount.
|
30
|
+
if (_this._container && _this._container !== container) {
|
31
|
+
_this.componentWillUnmount();
|
32
|
+
}
|
33
|
+
|
34
|
+
// When props.vnode is undefined/false/null we are dealing with some kind of
|
35
|
+
// conditional vnode. This should not trigger a render.
|
36
|
+
if (props._vnode) {
|
37
|
+
if (!_this._temp) {
|
38
|
+
_this._container = container;
|
39
|
+
|
40
|
+
// Create a fake DOM parent node that manages a subset of `container`'s children:
|
41
|
+
_this._temp = {
|
42
|
+
nodeType: 1,
|
43
|
+
parentNode: container,
|
44
|
+
childNodes: [],
|
45
|
+
appendChild(child) {
|
46
|
+
this.childNodes.push(child);
|
47
|
+
_this._container.appendChild(child);
|
48
|
+
},
|
49
|
+
insertBefore(child, before) {
|
50
|
+
this.childNodes.push(child);
|
51
|
+
_this._container.appendChild(child);
|
52
|
+
},
|
53
|
+
removeChild(child) {
|
54
|
+
this.childNodes.splice(this.childNodes.indexOf(child) >>> 1, 1);
|
55
|
+
_this._container.removeChild(child);
|
56
|
+
}
|
57
|
+
};
|
58
|
+
}
|
59
|
+
|
60
|
+
// Render our wrapping element into temp.
|
61
|
+
render(
|
62
|
+
createElement(ContextProvider, { context: _this.context }, props._vnode),
|
63
|
+
_this._temp
|
64
|
+
);
|
65
|
+
}
|
66
|
+
// When we come from a conditional render, on a mounted
|
67
|
+
// portal we should clear the DOM.
|
68
|
+
else if (_this._temp) {
|
69
|
+
_this.componentWillUnmount();
|
70
|
+
}
|
71
|
+
}
|
72
|
+
|
73
|
+
/**
|
74
|
+
* Create a `Portal` to continue rendering the vnode tree at a different DOM node
|
75
|
+
* @param {import('./internal').VNode} vnode The vnode to render
|
76
|
+
* @param {import('./internal').PreactElement} container The DOM node to continue rendering in to.
|
77
|
+
*/
|
78
|
+
export function createPortal(vnode, container) {
|
79
|
+
return createElement(Portal, { _vnode: vnode, _container: container });
|
80
|
+
}
|
@@ -1,230 +1,229 @@
|
|
1
|
-
import {
|
2
|
-
render as preactRender,
|
3
|
-
hydrate as preactHydrate,
|
4
|
-
options,
|
5
|
-
toChildArray,
|
6
|
-
Component
|
7
|
-
} from 'preact';
|
8
|
-
|
9
|
-
export const REACT_ELEMENT_TYPE =
|
10
|
-
(typeof Symbol != 'undefined' && Symbol.for && Symbol.for('react.element')) ||
|
11
|
-
0xeac7;
|
12
|
-
|
13
|
-
const CAMEL_PROPS = /^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|marker(?!H|W|U)|overline|paint|stop|strikethrough|stroke|text(?!L)|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/;
|
14
|
-
|
15
|
-
const IS_DOM = typeof document !== 'undefined';
|
16
|
-
|
17
|
-
// Input types for which onchange should not be converted to oninput.
|
18
|
-
// type="file|checkbox|radio", plus "range" in IE11.
|
19
|
-
// (IE11 doesn't support Symbol, which we use here to turn `rad` into `ra` which matches "range")
|
20
|
-
const onChangeInputType = type =>
|
21
|
-
(typeof Symbol != 'undefined' && typeof Symbol() == 'symbol'
|
22
|
-
? /fil|che|rad/i
|
23
|
-
: /fil|che|ra/i
|
24
|
-
).test(type);
|
25
|
-
|
26
|
-
// Some libraries like `react-virtualized` explicitly check for this.
|
27
|
-
Component.prototype.isReactComponent = {};
|
28
|
-
|
29
|
-
// `UNSAFE_*` lifecycle hooks
|
30
|
-
// Preact only ever invokes the unprefixed methods.
|
31
|
-
// Here we provide a base "fallback" implementation that calls any defined UNSAFE_ prefixed method.
|
32
|
-
// - If a component defines its own `componentDidMount()` (including via defineProperty), use that.
|
33
|
-
// - If a component defines `UNSAFE_componentDidMount()`, `componentDidMount` is the alias getter/setter.
|
34
|
-
// - If anything assigns to an `UNSAFE_*` property, the assignment is forwarded to the unprefixed property.
|
35
|
-
// See https://github.com/preactjs/preact/issues/1941
|
36
|
-
[
|
37
|
-
'componentWillMount',
|
38
|
-
'componentWillReceiveProps',
|
39
|
-
'componentWillUpdate'
|
40
|
-
].forEach(key => {
|
41
|
-
Object.defineProperty(Component.prototype, key, {
|
42
|
-
configurable: true,
|
43
|
-
get() {
|
44
|
-
return this['UNSAFE_' + key];
|
45
|
-
},
|
46
|
-
set(v) {
|
47
|
-
Object.defineProperty(this, key, {
|
48
|
-
configurable: true,
|
49
|
-
writable: true,
|
50
|
-
value: v
|
51
|
-
});
|
52
|
-
}
|
53
|
-
});
|
54
|
-
});
|
55
|
-
|
56
|
-
/**
|
57
|
-
* Proxy render() since React returns a Component reference.
|
58
|
-
* @param {import('./internal').VNode} vnode VNode tree to render
|
59
|
-
* @param {import('./internal').PreactElement} parent DOM node to render vnode tree into
|
60
|
-
* @param {() => void} [callback] Optional callback that will be called after rendering
|
61
|
-
* @returns {import('./internal').Component | null} The root component reference or null
|
62
|
-
*/
|
63
|
-
export function render(vnode, parent, callback) {
|
64
|
-
// React destroys any existing DOM nodes, see #1727
|
65
|
-
// ...but only on the first render, see #1828
|
66
|
-
if (parent._children == null) {
|
67
|
-
parent.textContent = '';
|
68
|
-
}
|
69
|
-
|
70
|
-
preactRender(vnode, parent);
|
71
|
-
if (typeof callback == 'function') callback();
|
72
|
-
|
73
|
-
return vnode ? vnode._component : null;
|
74
|
-
}
|
75
|
-
|
76
|
-
export function hydrate(vnode, parent, callback) {
|
77
|
-
preactHydrate(vnode, parent);
|
78
|
-
if (typeof callback == 'function') callback();
|
79
|
-
|
80
|
-
return vnode ? vnode._component : null;
|
81
|
-
}
|
82
|
-
|
83
|
-
let oldEventHook = options.event;
|
84
|
-
options.event = e => {
|
85
|
-
if (oldEventHook) e = oldEventHook(e);
|
86
|
-
e.persist = empty;
|
87
|
-
e.isPropagationStopped = isPropagationStopped;
|
88
|
-
e.isDefaultPrevented = isDefaultPrevented;
|
89
|
-
return (e.nativeEvent = e);
|
90
|
-
};
|
91
|
-
|
92
|
-
function empty() {}
|
93
|
-
|
94
|
-
function isPropagationStopped() {
|
95
|
-
return this.cancelBubble;
|
96
|
-
}
|
97
|
-
|
98
|
-
function isDefaultPrevented() {
|
99
|
-
return this.defaultPrevented;
|
100
|
-
}
|
101
|
-
|
102
|
-
let classNameDescriptor = {
|
103
|
-
configurable: true,
|
104
|
-
get() {
|
105
|
-
return this.class;
|
106
|
-
}
|
107
|
-
};
|
108
|
-
|
109
|
-
let oldVNodeHook = options.vnode;
|
110
|
-
options.vnode = vnode => {
|
111
|
-
let type = vnode.type;
|
112
|
-
let props = vnode.props;
|
113
|
-
let normalizedProps = props;
|
114
|
-
|
115
|
-
// only normalize props on Element nodes
|
116
|
-
if (typeof type === 'string') {
|
117
|
-
const nonCustomElement = type.indexOf('-') === -1;
|
118
|
-
normalizedProps = {};
|
119
|
-
|
120
|
-
for (let i in props) {
|
121
|
-
let value = props[i];
|
122
|
-
|
123
|
-
if (IS_DOM && i === 'children' && type === 'noscript') {
|
124
|
-
// Emulate React's behavior of not rendering the contents of noscript tags on the client.
|
125
|
-
continue;
|
126
|
-
}
|
127
|
-
|
128
|
-
//
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
// `defaultValue`
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
//
|
141
|
-
//
|
142
|
-
//
|
143
|
-
//
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
normalizedProps.
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
//
|
219
|
-
//
|
220
|
-
//
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
};
|
1
|
+
import {
|
2
|
+
render as preactRender,
|
3
|
+
hydrate as preactHydrate,
|
4
|
+
options,
|
5
|
+
toChildArray,
|
6
|
+
Component
|
7
|
+
} from 'preact';
|
8
|
+
|
9
|
+
export const REACT_ELEMENT_TYPE =
|
10
|
+
(typeof Symbol != 'undefined' && Symbol.for && Symbol.for('react.element')) ||
|
11
|
+
0xeac7;
|
12
|
+
|
13
|
+
const CAMEL_PROPS = /^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|marker(?!H|W|U)|overline|paint|stop|strikethrough|stroke|text(?!L)|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/;
|
14
|
+
|
15
|
+
const IS_DOM = typeof document !== 'undefined';
|
16
|
+
|
17
|
+
// Input types for which onchange should not be converted to oninput.
|
18
|
+
// type="file|checkbox|radio", plus "range" in IE11.
|
19
|
+
// (IE11 doesn't support Symbol, which we use here to turn `rad` into `ra` which matches "range")
|
20
|
+
const onChangeInputType = type =>
|
21
|
+
(typeof Symbol != 'undefined' && typeof Symbol() == 'symbol'
|
22
|
+
? /fil|che|rad/i
|
23
|
+
: /fil|che|ra/i
|
24
|
+
).test(type);
|
25
|
+
|
26
|
+
// Some libraries like `react-virtualized` explicitly check for this.
|
27
|
+
Component.prototype.isReactComponent = {};
|
28
|
+
|
29
|
+
// `UNSAFE_*` lifecycle hooks
|
30
|
+
// Preact only ever invokes the unprefixed methods.
|
31
|
+
// Here we provide a base "fallback" implementation that calls any defined UNSAFE_ prefixed method.
|
32
|
+
// - If a component defines its own `componentDidMount()` (including via defineProperty), use that.
|
33
|
+
// - If a component defines `UNSAFE_componentDidMount()`, `componentDidMount` is the alias getter/setter.
|
34
|
+
// - If anything assigns to an `UNSAFE_*` property, the assignment is forwarded to the unprefixed property.
|
35
|
+
// See https://github.com/preactjs/preact/issues/1941
|
36
|
+
[
|
37
|
+
'componentWillMount',
|
38
|
+
'componentWillReceiveProps',
|
39
|
+
'componentWillUpdate'
|
40
|
+
].forEach(key => {
|
41
|
+
Object.defineProperty(Component.prototype, key, {
|
42
|
+
configurable: true,
|
43
|
+
get() {
|
44
|
+
return this['UNSAFE_' + key];
|
45
|
+
},
|
46
|
+
set(v) {
|
47
|
+
Object.defineProperty(this, key, {
|
48
|
+
configurable: true,
|
49
|
+
writable: true,
|
50
|
+
value: v
|
51
|
+
});
|
52
|
+
}
|
53
|
+
});
|
54
|
+
});
|
55
|
+
|
56
|
+
/**
|
57
|
+
* Proxy render() since React returns a Component reference.
|
58
|
+
* @param {import('./internal').VNode} vnode VNode tree to render
|
59
|
+
* @param {import('./internal').PreactElement} parent DOM node to render vnode tree into
|
60
|
+
* @param {() => void} [callback] Optional callback that will be called after rendering
|
61
|
+
* @returns {import('./internal').Component | null} The root component reference or null
|
62
|
+
*/
|
63
|
+
export function render(vnode, parent, callback) {
|
64
|
+
// React destroys any existing DOM nodes, see #1727
|
65
|
+
// ...but only on the first render, see #1828
|
66
|
+
if (parent._children == null) {
|
67
|
+
parent.textContent = '';
|
68
|
+
}
|
69
|
+
|
70
|
+
preactRender(vnode, parent);
|
71
|
+
if (typeof callback == 'function') callback();
|
72
|
+
|
73
|
+
return vnode ? vnode._component : null;
|
74
|
+
}
|
75
|
+
|
76
|
+
export function hydrate(vnode, parent, callback) {
|
77
|
+
preactHydrate(vnode, parent);
|
78
|
+
if (typeof callback == 'function') callback();
|
79
|
+
|
80
|
+
return vnode ? vnode._component : null;
|
81
|
+
}
|
82
|
+
|
83
|
+
let oldEventHook = options.event;
|
84
|
+
options.event = e => {
|
85
|
+
if (oldEventHook) e = oldEventHook(e);
|
86
|
+
e.persist = empty;
|
87
|
+
e.isPropagationStopped = isPropagationStopped;
|
88
|
+
e.isDefaultPrevented = isDefaultPrevented;
|
89
|
+
return (e.nativeEvent = e);
|
90
|
+
};
|
91
|
+
|
92
|
+
function empty() {}
|
93
|
+
|
94
|
+
function isPropagationStopped() {
|
95
|
+
return this.cancelBubble;
|
96
|
+
}
|
97
|
+
|
98
|
+
function isDefaultPrevented() {
|
99
|
+
return this.defaultPrevented;
|
100
|
+
}
|
101
|
+
|
102
|
+
let classNameDescriptor = {
|
103
|
+
configurable: true,
|
104
|
+
get() {
|
105
|
+
return this.class;
|
106
|
+
}
|
107
|
+
};
|
108
|
+
|
109
|
+
let oldVNodeHook = options.vnode;
|
110
|
+
options.vnode = vnode => {
|
111
|
+
let type = vnode.type;
|
112
|
+
let props = vnode.props;
|
113
|
+
let normalizedProps = props;
|
114
|
+
|
115
|
+
// only normalize props on Element nodes
|
116
|
+
if (typeof type === 'string') {
|
117
|
+
const nonCustomElement = type.indexOf('-') === -1;
|
118
|
+
normalizedProps = {};
|
119
|
+
|
120
|
+
for (let i in props) {
|
121
|
+
let value = props[i];
|
122
|
+
|
123
|
+
if (IS_DOM && i === 'children' && type === 'noscript') {
|
124
|
+
// Emulate React's behavior of not rendering the contents of noscript tags on the client.
|
125
|
+
continue;
|
126
|
+
} else if (i === 'value' && 'defaultValue' in props && value == null) {
|
127
|
+
// Skip applying value if it is null/undefined and we already set
|
128
|
+
// a default value
|
129
|
+
continue;
|
130
|
+
} else if (
|
131
|
+
i === 'defaultValue' &&
|
132
|
+
'value' in props &&
|
133
|
+
props.value == null
|
134
|
+
) {
|
135
|
+
// `defaultValue` is treated as a fallback `value` when a value prop is present but null/undefined.
|
136
|
+
// `defaultValue` for Elements with no value prop is the same as the DOM defaultValue property.
|
137
|
+
i = 'value';
|
138
|
+
} else if (i === 'download' && value === true) {
|
139
|
+
// Calling `setAttribute` with a truthy value will lead to it being
|
140
|
+
// passed as a stringified value, e.g. `download="true"`. React
|
141
|
+
// converts it to an empty string instead, otherwise the attribute
|
142
|
+
// value will be used as the file name and the file will be called
|
143
|
+
// "true" upon downloading it.
|
144
|
+
value = '';
|
145
|
+
} else if (/ondoubleclick/i.test(i)) {
|
146
|
+
i = 'ondblclick';
|
147
|
+
} else if (
|
148
|
+
/^onchange(textarea|input)/i.test(i + type) &&
|
149
|
+
!onChangeInputType(props.type)
|
150
|
+
) {
|
151
|
+
i = 'oninput';
|
152
|
+
} else if (/^onfocus$/i.test(i)) {
|
153
|
+
i = 'onfocusin';
|
154
|
+
} else if (/^onblur$/i.test(i)) {
|
155
|
+
i = 'onfocusout';
|
156
|
+
} else if (/^on(Ani|Tra|Tou|BeforeInp|Compo)/.test(i)) {
|
157
|
+
i = i.toLowerCase();
|
158
|
+
} else if (nonCustomElement && CAMEL_PROPS.test(i)) {
|
159
|
+
i = i.replace(/[A-Z0-9]/, '-$&').toLowerCase();
|
160
|
+
} else if (value === null) {
|
161
|
+
value = undefined;
|
162
|
+
}
|
163
|
+
|
164
|
+
normalizedProps[i] = value;
|
165
|
+
}
|
166
|
+
|
167
|
+
// Add support for array select values: <select multiple value={[]} />
|
168
|
+
if (
|
169
|
+
type == 'select' &&
|
170
|
+
normalizedProps.multiple &&
|
171
|
+
Array.isArray(normalizedProps.value)
|
172
|
+
) {
|
173
|
+
// forEach() always returns undefined, which we abuse here to unset the value prop.
|
174
|
+
normalizedProps.value = toChildArray(props.children).forEach(child => {
|
175
|
+
child.props.selected =
|
176
|
+
normalizedProps.value.indexOf(child.props.value) != -1;
|
177
|
+
});
|
178
|
+
}
|
179
|
+
|
180
|
+
// Adding support for defaultValue in select tag
|
181
|
+
if (type == 'select' && normalizedProps.defaultValue != null) {
|
182
|
+
normalizedProps.value = toChildArray(props.children).forEach(child => {
|
183
|
+
if (normalizedProps.multiple) {
|
184
|
+
child.props.selected =
|
185
|
+
normalizedProps.defaultValue.indexOf(child.props.value) != -1;
|
186
|
+
} else {
|
187
|
+
child.props.selected =
|
188
|
+
normalizedProps.defaultValue == child.props.value;
|
189
|
+
}
|
190
|
+
});
|
191
|
+
}
|
192
|
+
|
193
|
+
vnode.props = normalizedProps;
|
194
|
+
|
195
|
+
if (props.class != props.className) {
|
196
|
+
classNameDescriptor.enumerable = 'className' in props;
|
197
|
+
if (props.className != null) normalizedProps.class = props.className;
|
198
|
+
Object.defineProperty(normalizedProps, 'className', classNameDescriptor);
|
199
|
+
}
|
200
|
+
}
|
201
|
+
|
202
|
+
vnode.$$typeof = REACT_ELEMENT_TYPE;
|
203
|
+
|
204
|
+
if (oldVNodeHook) oldVNodeHook(vnode);
|
205
|
+
};
|
206
|
+
|
207
|
+
// Only needed for react-relay
|
208
|
+
let currentComponent;
|
209
|
+
const oldBeforeRender = options._render;
|
210
|
+
options._render = function(vnode) {
|
211
|
+
if (oldBeforeRender) {
|
212
|
+
oldBeforeRender(vnode);
|
213
|
+
}
|
214
|
+
currentComponent = vnode._component;
|
215
|
+
};
|
216
|
+
|
217
|
+
// This is a very very private internal function for React it
|
218
|
+
// is used to sort-of do runtime dependency injection. So far
|
219
|
+
// only `react-relay` makes use of it. It uses it to read the
|
220
|
+
// context value.
|
221
|
+
export const __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = {
|
222
|
+
ReactCurrentDispatcher: {
|
223
|
+
current: {
|
224
|
+
readContext(context) {
|
225
|
+
return currentComponent._globalContext[context._id].props.value;
|
226
|
+
}
|
227
|
+
}
|
228
|
+
}
|
229
|
+
};
|
@@ -1,14 +1,14 @@
|
|
1
|
-
import { Component, ComponentChild, ComponentChildren } from '../../src';
|
2
|
-
|
3
|
-
//
|
4
|
-
// SuspenseList
|
5
|
-
// -----------------------------------
|
6
|
-
|
7
|
-
export interface SuspenseListProps {
|
8
|
-
children?: ComponentChildren;
|
9
|
-
revealOrder?: 'forwards' | 'backwards' | 'together';
|
10
|
-
}
|
11
|
-
|
12
|
-
export class SuspenseList extends Component<SuspenseListProps> {
|
13
|
-
render(): ComponentChild;
|
14
|
-
}
|
1
|
+
import { Component, ComponentChild, ComponentChildren } from '../../src';
|
2
|
+
|
3
|
+
//
|
4
|
+
// SuspenseList
|
5
|
+
// -----------------------------------
|
6
|
+
|
7
|
+
export interface SuspenseListProps {
|
8
|
+
children?: ComponentChildren;
|
9
|
+
revealOrder?: 'forwards' | 'backwards' | 'together';
|
10
|
+
}
|
11
|
+
|
12
|
+
export class SuspenseList extends Component<SuspenseListProps> {
|
13
|
+
render(): ComponentChild;
|
14
|
+
}
|