isomorfeus-preact 10.6.13 → 10.6.17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (123) hide show
  1. checksums.yaml +4 -4
  2. data/lib/isomorfeus/preact_view_helper.rb +3 -2
  3. data/lib/isomorfeus-preact.rb +4 -4
  4. data/lib/isomorfeus_preact/lucid_component/api.rb +1 -1
  5. data/lib/isomorfeus_preact/lucid_component/initializer.rb +2 -4
  6. data/lib/isomorfeus_preact/lucid_func/initializer.rb +1 -1
  7. data/lib/isomorfeus_preact/preact/function_component/initializer.rb +1 -1
  8. data/lib/preact/component/api.rb +2 -2
  9. data/lib/preact/component/callbacks.rb +6 -6
  10. data/lib/preact/component/initializer.rb +2 -2
  11. data/lib/preact/component/native_component_constructor.rb +1 -1
  12. data/lib/preact/component/resolution.rb +2 -2
  13. data/lib/preact/params.rb +16 -0
  14. data/lib/preact/props.rb +69 -0
  15. data/lib/preact/state.rb +87 -0
  16. data/lib/preact/version.rb +1 -1
  17. data/lib/preact.rb +2 -2
  18. data/node_modules/.package-lock.json +3 -3
  19. data/node_modules/preact/LICENSE +21 -21
  20. data/node_modules/preact/README.md +187 -187
  21. data/node_modules/preact/compat/dist/compat.js +1 -1
  22. data/node_modules/preact/compat/dist/compat.js.map +1 -1
  23. data/node_modules/preact/compat/dist/compat.mjs +1 -1
  24. data/node_modules/preact/compat/dist/compat.module.js +1 -1
  25. data/node_modules/preact/compat/dist/compat.module.js.map +1 -1
  26. data/node_modules/preact/compat/dist/compat.umd.js +1 -1
  27. data/node_modules/preact/compat/dist/compat.umd.js.map +1 -1
  28. data/node_modules/preact/compat/jsx-dev-runtime.js +1 -1
  29. data/node_modules/preact/compat/jsx-dev-runtime.mjs +1 -1
  30. data/node_modules/preact/compat/jsx-runtime.js +1 -1
  31. data/node_modules/preact/compat/jsx-runtime.mjs +1 -1
  32. data/node_modules/preact/compat/package.json +19 -19
  33. data/node_modules/preact/compat/scheduler.js +15 -15
  34. data/node_modules/preact/compat/scheduler.mjs +23 -23
  35. data/node_modules/preact/compat/server.js +15 -15
  36. data/node_modules/preact/compat/server.mjs +4 -4
  37. data/node_modules/preact/compat/src/Children.js +21 -21
  38. data/node_modules/preact/compat/src/PureComponent.js +15 -15
  39. data/node_modules/preact/compat/src/forwardRef.js +51 -51
  40. data/node_modules/preact/compat/src/index.d.ts +141 -141
  41. data/node_modules/preact/compat/src/index.js +187 -187
  42. data/node_modules/preact/compat/src/internal.d.ts +47 -47
  43. data/node_modules/preact/compat/src/memo.js +34 -34
  44. data/node_modules/preact/compat/src/portals.js +80 -80
  45. data/node_modules/preact/compat/src/render.js +229 -230
  46. data/node_modules/preact/compat/src/suspense-list.d.ts +14 -14
  47. data/node_modules/preact/compat/src/suspense-list.js +126 -126
  48. data/node_modules/preact/compat/src/suspense.d.ts +15 -15
  49. data/node_modules/preact/compat/src/suspense.js +270 -270
  50. data/node_modules/preact/compat/src/util.js +28 -28
  51. data/node_modules/preact/compat/test-utils.js +1 -1
  52. data/node_modules/preact/debug/dist/debug.js.map +1 -1
  53. data/node_modules/preact/debug/dist/debug.module.js.map +1 -1
  54. data/node_modules/preact/debug/dist/debug.umd.js.map +1 -1
  55. data/node_modules/preact/debug/package.json +18 -18
  56. data/node_modules/preact/debug/src/check-props.js +54 -54
  57. data/node_modules/preact/debug/src/component-stack.js +146 -146
  58. data/node_modules/preact/debug/src/constants.js +3 -3
  59. data/node_modules/preact/debug/src/debug.js +442 -442
  60. data/node_modules/preact/debug/src/index.js +6 -6
  61. data/node_modules/preact/debug/src/internal.d.ts +82 -82
  62. data/node_modules/preact/debug/src/util.js +11 -11
  63. data/node_modules/preact/devtools/dist/devtools.js +1 -1
  64. data/node_modules/preact/devtools/dist/devtools.js.map +1 -1
  65. data/node_modules/preact/devtools/dist/devtools.mjs +1 -1
  66. data/node_modules/preact/devtools/dist/devtools.module.js +1 -1
  67. data/node_modules/preact/devtools/dist/devtools.module.js.map +1 -1
  68. data/node_modules/preact/devtools/dist/devtools.umd.js +1 -1
  69. data/node_modules/preact/devtools/dist/devtools.umd.js.map +1 -1
  70. data/node_modules/preact/devtools/package.json +16 -16
  71. data/node_modules/preact/devtools/src/devtools.js +10 -10
  72. data/node_modules/preact/devtools/src/index.d.ts +8 -8
  73. data/node_modules/preact/devtools/src/index.js +15 -15
  74. data/node_modules/preact/dist/preact.js.map +1 -1
  75. data/node_modules/preact/dist/preact.min.js.map +1 -1
  76. data/node_modules/preact/dist/preact.module.js.map +1 -1
  77. data/node_modules/preact/dist/preact.umd.js.map +1 -1
  78. data/node_modules/preact/hooks/dist/hooks.js +1 -1
  79. data/node_modules/preact/hooks/dist/hooks.js.map +1 -1
  80. data/node_modules/preact/hooks/dist/hooks.mjs +1 -1
  81. data/node_modules/preact/hooks/dist/hooks.module.js +1 -1
  82. data/node_modules/preact/hooks/dist/hooks.module.js.map +1 -1
  83. data/node_modules/preact/hooks/dist/hooks.umd.js +1 -1
  84. data/node_modules/preact/hooks/dist/hooks.umd.js.map +1 -1
  85. data/node_modules/preact/hooks/package.json +26 -26
  86. data/node_modules/preact/hooks/src/index.d.ts +139 -139
  87. data/node_modules/preact/hooks/src/index.js +386 -388
  88. data/node_modules/preact/hooks/src/internal.d.ts +75 -75
  89. data/node_modules/preact/jsx-runtime/dist/jsxRuntime.js.map +1 -1
  90. data/node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js.map +1 -1
  91. data/node_modules/preact/jsx-runtime/dist/jsxRuntime.umd.js.map +1 -1
  92. data/node_modules/preact/jsx-runtime/package.json +19 -19
  93. data/node_modules/preact/jsx-runtime/src/index.d.ts +50 -50
  94. data/node_modules/preact/jsx-runtime/src/index.js +77 -77
  95. data/node_modules/preact/package.json +291 -287
  96. data/node_modules/preact/src/cjs.js +3 -3
  97. data/node_modules/preact/src/clone-element.js +34 -34
  98. data/node_modules/preact/src/component.js +225 -225
  99. data/node_modules/preact/src/constants.js +3 -3
  100. data/node_modules/preact/src/create-context.js +68 -68
  101. data/node_modules/preact/src/create-element.js +98 -98
  102. data/node_modules/preact/src/diff/catch-error.js +38 -38
  103. data/node_modules/preact/src/diff/children.js +335 -335
  104. data/node_modules/preact/src/diff/index.js +516 -516
  105. data/node_modules/preact/src/diff/props.js +158 -158
  106. data/node_modules/preact/src/index.d.ts +310 -310
  107. data/node_modules/preact/src/index.js +13 -13
  108. data/node_modules/preact/src/internal.d.ts +146 -146
  109. data/node_modules/preact/src/jsx.d.ts +1005 -1005
  110. data/node_modules/preact/src/options.js +16 -16
  111. data/node_modules/preact/src/render.js +75 -75
  112. data/node_modules/preact/src/util.js +27 -27
  113. data/node_modules/preact/test-utils/dist/testUtils.js.map +1 -1
  114. data/node_modules/preact/test-utils/dist/testUtils.module.js.map +1 -1
  115. data/node_modules/preact/test-utils/dist/testUtils.umd.js.map +1 -1
  116. data/node_modules/preact/test-utils/package.json +19 -19
  117. data/node_modules/preact/test-utils/src/index.d.ts +3 -3
  118. data/node_modules/preact/test-utils/src/index.js +117 -117
  119. data/package.json +1 -1
  120. metadata +9 -9
  121. data/lib/preact/component/params.rb +0 -18
  122. data/lib/preact/component/props.rb +0 -55
  123. 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
- else if (i === 'value' && 'defaultValue' in props && value == null) {
128
- // Skip applying value if it is null/undefined and we already set
129
- // a default value
130
- continue;
131
- } else if (
132
- i === 'defaultValue' &&
133
- 'value' in props &&
134
- props.value == null
135
- ) {
136
- // `defaultValue` is treated as a fallback `value` when a value prop is present but null/undefined.
137
- // `defaultValue` for Elements with no value prop is the same as the DOM defaultValue property.
138
- i = 'value';
139
- } else if (i === 'download' && value === true) {
140
- // Calling `setAttribute` with a truthy value will lead to it being
141
- // passed as a stringified value, e.g. `download="true"`. React
142
- // converts it to an empty string instead, otherwise the attribute
143
- // value will be used as the file name and the file will be called
144
- // "true" upon downloading it.
145
- value = '';
146
- } else if (/ondoubleclick/i.test(i)) {
147
- i = 'ondblclick';
148
- } else if (
149
- /^onchange(textarea|input)/i.test(i + type) &&
150
- !onChangeInputType(props.type)
151
- ) {
152
- i = 'oninput';
153
- } else if (/^onfocus$/i.test(i)) {
154
- i = 'onfocusin';
155
- } else if (/^onblur$/i.test(i)) {
156
- i = 'onfocusout';
157
- } else if (/^on(Ani|Tra|Tou|BeforeInp)/.test(i)) {
158
- i = i.toLowerCase();
159
- } else if (nonCustomElement && CAMEL_PROPS.test(i)) {
160
- i = i.replace(/[A-Z0-9]/, '-$&').toLowerCase();
161
- } else if (value === null) {
162
- value = undefined;
163
- }
164
-
165
- normalizedProps[i] = value;
166
- }
167
-
168
- // Add support for array select values: <select multiple value={[]} />
169
- if (
170
- type == 'select' &&
171
- normalizedProps.multiple &&
172
- Array.isArray(normalizedProps.value)
173
- ) {
174
- // forEach() always returns undefined, which we abuse here to unset the value prop.
175
- normalizedProps.value = toChildArray(props.children).forEach(child => {
176
- child.props.selected =
177
- normalizedProps.value.indexOf(child.props.value) != -1;
178
- });
179
- }
180
-
181
- // Adding support for defaultValue in select tag
182
- if (type == 'select' && normalizedProps.defaultValue != null) {
183
- normalizedProps.value = toChildArray(props.children).forEach(child => {
184
- if (normalizedProps.multiple) {
185
- child.props.selected =
186
- normalizedProps.defaultValue.indexOf(child.props.value) != -1;
187
- } else {
188
- child.props.selected =
189
- normalizedProps.defaultValue == child.props.value;
190
- }
191
- });
192
- }
193
-
194
- vnode.props = normalizedProps;
195
-
196
- if (props.class != props.className) {
197
- classNameDescriptor.enumerable = 'className' in props;
198
- if (props.className != null) normalizedProps.class = props.className;
199
- Object.defineProperty(normalizedProps, 'className', classNameDescriptor);
200
- }
201
- }
202
-
203
- vnode.$$typeof = REACT_ELEMENT_TYPE;
204
-
205
- if (oldVNodeHook) oldVNodeHook(vnode);
206
- };
207
-
208
- // Only needed for react-relay
209
- let currentComponent;
210
- const oldBeforeRender = options._render;
211
- options._render = function(vnode) {
212
- if (oldBeforeRender) {
213
- oldBeforeRender(vnode);
214
- }
215
- currentComponent = vnode._component;
216
- };
217
-
218
- // This is a very very private internal function for React it
219
- // is used to sort-of do runtime dependency injection. So far
220
- // only `react-relay` makes use of it. It uses it to read the
221
- // context value.
222
- export const __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = {
223
- ReactCurrentDispatcher: {
224
- current: {
225
- readContext(context) {
226
- return currentComponent._globalContext[context._id].props.value;
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
+ }