isomorfeus-preact 10.6.11 → 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/browser/event.rb +2 -0
- data/lib/isomorfeus/preact_view_helper.rb +3 -2
- data/lib/isomorfeus/props/validate_hash_proxy.rb +1 -1
- data/lib/isomorfeus/props/validator.rb +6 -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 +8 -8
- data/lib/preact/component/props.rb +0 -55
- data/lib/preact/component/state.rb +0 -58
@@ -1,158 +1,158 @@
|
|
1
|
-
import { IS_NON_DIMENSIONAL } from '../constants';
|
2
|
-
import options from '../options';
|
3
|
-
|
4
|
-
/**
|
5
|
-
* Diff the old and new properties of a VNode and apply changes to the DOM node
|
6
|
-
* @param {import('../internal').PreactElement} dom The DOM node to apply
|
7
|
-
* changes to
|
8
|
-
* @param {object} newProps The new props
|
9
|
-
* @param {object} oldProps The old props
|
10
|
-
* @param {boolean} isSvg Whether or not this node is an SVG node
|
11
|
-
* @param {boolean} hydrate Whether or not we are in hydration mode
|
12
|
-
*/
|
13
|
-
export function diffProps(dom, newProps, oldProps, isSvg, hydrate) {
|
14
|
-
let i;
|
15
|
-
|
16
|
-
for (i in oldProps) {
|
17
|
-
if (i !== 'children' && i !== 'key' && !(i in newProps)) {
|
18
|
-
setProperty(dom, i, null, oldProps[i], isSvg);
|
19
|
-
}
|
20
|
-
}
|
21
|
-
|
22
|
-
for (i in newProps) {
|
23
|
-
if (
|
24
|
-
(!hydrate || typeof newProps[i] == 'function') &&
|
25
|
-
i !== 'children' &&
|
26
|
-
i !== 'key' &&
|
27
|
-
i !== 'value' &&
|
28
|
-
i !== 'checked' &&
|
29
|
-
oldProps[i] !== newProps[i]
|
30
|
-
) {
|
31
|
-
setProperty(dom, i, newProps[i], oldProps[i], isSvg);
|
32
|
-
}
|
33
|
-
}
|
34
|
-
}
|
35
|
-
|
36
|
-
function setStyle(style, key, value) {
|
37
|
-
if (key[0] === '-') {
|
38
|
-
style.setProperty(key, value);
|
39
|
-
} else if (value == null) {
|
40
|
-
style[key] = '';
|
41
|
-
} else if (typeof value != 'number' || IS_NON_DIMENSIONAL.test(key)) {
|
42
|
-
style[key] = value;
|
43
|
-
} else {
|
44
|
-
style[key] = value + 'px';
|
45
|
-
}
|
46
|
-
}
|
47
|
-
|
48
|
-
/**
|
49
|
-
* Set a property value on a DOM node
|
50
|
-
* @param {import('../internal').PreactElement} dom The DOM node to modify
|
51
|
-
* @param {string} name The name of the property to set
|
52
|
-
* @param {*} value The value to set the property to
|
53
|
-
* @param {*} oldValue The old value the property had
|
54
|
-
* @param {boolean} isSvg Whether or not this DOM node is an SVG node or not
|
55
|
-
*/
|
56
|
-
export function setProperty(dom, name, value, oldValue, isSvg) {
|
57
|
-
let useCapture;
|
58
|
-
|
59
|
-
o: if (name === 'style') {
|
60
|
-
if (typeof value == 'string') {
|
61
|
-
dom.style.cssText = value;
|
62
|
-
} else {
|
63
|
-
if (typeof oldValue == 'string') {
|
64
|
-
dom.style.cssText = oldValue = '';
|
65
|
-
}
|
66
|
-
|
67
|
-
if (oldValue) {
|
68
|
-
for (name in oldValue) {
|
69
|
-
if (!(value && name in value)) {
|
70
|
-
setStyle(dom.style, name, '');
|
71
|
-
}
|
72
|
-
}
|
73
|
-
}
|
74
|
-
|
75
|
-
if (value) {
|
76
|
-
for (name in value) {
|
77
|
-
if (!oldValue || value[name] !== oldValue[name]) {
|
78
|
-
setStyle(dom.style, name, value[name]);
|
79
|
-
}
|
80
|
-
}
|
81
|
-
}
|
82
|
-
}
|
83
|
-
}
|
84
|
-
// Benchmark for comparison: https://esbench.com/bench/574c954bdb965b9a00965ac6
|
85
|
-
else if (name[0] === 'o' && name[1] === 'n') {
|
86
|
-
useCapture = name !== (name = name.replace(/Capture$/, ''));
|
87
|
-
|
88
|
-
// Infer correct casing for DOM built-in events:
|
89
|
-
if (name.toLowerCase() in dom) name = name.toLowerCase().slice(2);
|
90
|
-
else name = name.slice(2);
|
91
|
-
|
92
|
-
if (!dom._listeners) dom._listeners = {};
|
93
|
-
dom._listeners[name + useCapture] = value;
|
94
|
-
|
95
|
-
if (value) {
|
96
|
-
if (!oldValue) {
|
97
|
-
const handler = useCapture ? eventProxyCapture : eventProxy;
|
98
|
-
dom.addEventListener(name, handler, useCapture);
|
99
|
-
}
|
100
|
-
} else {
|
101
|
-
const handler = useCapture ? eventProxyCapture : eventProxy;
|
102
|
-
dom.removeEventListener(name, handler, useCapture);
|
103
|
-
}
|
104
|
-
} else if (name !== 'dangerouslySetInnerHTML') {
|
105
|
-
if (isSvg) {
|
106
|
-
// Normalize incorrect prop usage for SVG:
|
107
|
-
// - xlink:href / xlinkHref --> href (xlink:href was removed from SVG and isn't needed)
|
108
|
-
// - className --> class
|
109
|
-
name = name.replace(/xlink[H:h]/, 'h').replace(/sName$/, 's');
|
110
|
-
} else if (
|
111
|
-
name !== 'href' &&
|
112
|
-
name !== 'list' &&
|
113
|
-
name !== 'form' &&
|
114
|
-
// Default value in browsers is `-1` and an empty string is
|
115
|
-
// cast to `0` instead
|
116
|
-
name !== 'tabIndex' &&
|
117
|
-
name !== 'download' &&
|
118
|
-
name in dom
|
119
|
-
) {
|
120
|
-
try {
|
121
|
-
dom[name] = value == null ? '' : value;
|
122
|
-
// labelled break is 1b smaller here than a return statement (sorry)
|
123
|
-
break o;
|
124
|
-
} catch (e) {}
|
125
|
-
}
|
126
|
-
|
127
|
-
// ARIA-attributes have a different notion of boolean values.
|
128
|
-
// The value `false` is different from the attribute not
|
129
|
-
// existing on the DOM, so we can't remove it. For non-boolean
|
130
|
-
// ARIA-attributes we could treat false as a removal, but the
|
131
|
-
// amount of exceptions would cost us too many bytes. On top of
|
132
|
-
// that other VDOM frameworks also always stringify `false`.
|
133
|
-
|
134
|
-
if (typeof value === 'function') {
|
135
|
-
// never serialize functions as attribute values
|
136
|
-
} else if (
|
137
|
-
value != null &&
|
138
|
-
(value !== false || (name[0] === 'a' && name[1] === 'r'))
|
139
|
-
) {
|
140
|
-
dom.setAttribute(name, value);
|
141
|
-
} else {
|
142
|
-
dom.removeAttribute(name);
|
143
|
-
}
|
144
|
-
}
|
145
|
-
}
|
146
|
-
|
147
|
-
/**
|
148
|
-
* Proxy an event to hooked event handlers
|
149
|
-
* @param {Event} e The event object from the browser
|
150
|
-
* @private
|
151
|
-
*/
|
152
|
-
function eventProxy(e) {
|
153
|
-
this._listeners[e.type + false](options.event ? options.event(e) : e);
|
154
|
-
}
|
155
|
-
|
156
|
-
function eventProxyCapture(e) {
|
157
|
-
this._listeners[e.type + true](options.event ? options.event(e) : e);
|
158
|
-
}
|
1
|
+
import { IS_NON_DIMENSIONAL } from '../constants';
|
2
|
+
import options from '../options';
|
3
|
+
|
4
|
+
/**
|
5
|
+
* Diff the old and new properties of a VNode and apply changes to the DOM node
|
6
|
+
* @param {import('../internal').PreactElement} dom The DOM node to apply
|
7
|
+
* changes to
|
8
|
+
* @param {object} newProps The new props
|
9
|
+
* @param {object} oldProps The old props
|
10
|
+
* @param {boolean} isSvg Whether or not this node is an SVG node
|
11
|
+
* @param {boolean} hydrate Whether or not we are in hydration mode
|
12
|
+
*/
|
13
|
+
export function diffProps(dom, newProps, oldProps, isSvg, hydrate) {
|
14
|
+
let i;
|
15
|
+
|
16
|
+
for (i in oldProps) {
|
17
|
+
if (i !== 'children' && i !== 'key' && !(i in newProps)) {
|
18
|
+
setProperty(dom, i, null, oldProps[i], isSvg);
|
19
|
+
}
|
20
|
+
}
|
21
|
+
|
22
|
+
for (i in newProps) {
|
23
|
+
if (
|
24
|
+
(!hydrate || typeof newProps[i] == 'function') &&
|
25
|
+
i !== 'children' &&
|
26
|
+
i !== 'key' &&
|
27
|
+
i !== 'value' &&
|
28
|
+
i !== 'checked' &&
|
29
|
+
oldProps[i] !== newProps[i]
|
30
|
+
) {
|
31
|
+
setProperty(dom, i, newProps[i], oldProps[i], isSvg);
|
32
|
+
}
|
33
|
+
}
|
34
|
+
}
|
35
|
+
|
36
|
+
function setStyle(style, key, value) {
|
37
|
+
if (key[0] === '-') {
|
38
|
+
style.setProperty(key, value);
|
39
|
+
} else if (value == null) {
|
40
|
+
style[key] = '';
|
41
|
+
} else if (typeof value != 'number' || IS_NON_DIMENSIONAL.test(key)) {
|
42
|
+
style[key] = value;
|
43
|
+
} else {
|
44
|
+
style[key] = value + 'px';
|
45
|
+
}
|
46
|
+
}
|
47
|
+
|
48
|
+
/**
|
49
|
+
* Set a property value on a DOM node
|
50
|
+
* @param {import('../internal').PreactElement} dom The DOM node to modify
|
51
|
+
* @param {string} name The name of the property to set
|
52
|
+
* @param {*} value The value to set the property to
|
53
|
+
* @param {*} oldValue The old value the property had
|
54
|
+
* @param {boolean} isSvg Whether or not this DOM node is an SVG node or not
|
55
|
+
*/
|
56
|
+
export function setProperty(dom, name, value, oldValue, isSvg) {
|
57
|
+
let useCapture;
|
58
|
+
|
59
|
+
o: if (name === 'style') {
|
60
|
+
if (typeof value == 'string') {
|
61
|
+
dom.style.cssText = value;
|
62
|
+
} else {
|
63
|
+
if (typeof oldValue == 'string') {
|
64
|
+
dom.style.cssText = oldValue = '';
|
65
|
+
}
|
66
|
+
|
67
|
+
if (oldValue) {
|
68
|
+
for (name in oldValue) {
|
69
|
+
if (!(value && name in value)) {
|
70
|
+
setStyle(dom.style, name, '');
|
71
|
+
}
|
72
|
+
}
|
73
|
+
}
|
74
|
+
|
75
|
+
if (value) {
|
76
|
+
for (name in value) {
|
77
|
+
if (!oldValue || value[name] !== oldValue[name]) {
|
78
|
+
setStyle(dom.style, name, value[name]);
|
79
|
+
}
|
80
|
+
}
|
81
|
+
}
|
82
|
+
}
|
83
|
+
}
|
84
|
+
// Benchmark for comparison: https://esbench.com/bench/574c954bdb965b9a00965ac6
|
85
|
+
else if (name[0] === 'o' && name[1] === 'n') {
|
86
|
+
useCapture = name !== (name = name.replace(/Capture$/, ''));
|
87
|
+
|
88
|
+
// Infer correct casing for DOM built-in events:
|
89
|
+
if (name.toLowerCase() in dom) name = name.toLowerCase().slice(2);
|
90
|
+
else name = name.slice(2);
|
91
|
+
|
92
|
+
if (!dom._listeners) dom._listeners = {};
|
93
|
+
dom._listeners[name + useCapture] = value;
|
94
|
+
|
95
|
+
if (value) {
|
96
|
+
if (!oldValue) {
|
97
|
+
const handler = useCapture ? eventProxyCapture : eventProxy;
|
98
|
+
dom.addEventListener(name, handler, useCapture);
|
99
|
+
}
|
100
|
+
} else {
|
101
|
+
const handler = useCapture ? eventProxyCapture : eventProxy;
|
102
|
+
dom.removeEventListener(name, handler, useCapture);
|
103
|
+
}
|
104
|
+
} else if (name !== 'dangerouslySetInnerHTML') {
|
105
|
+
if (isSvg) {
|
106
|
+
// Normalize incorrect prop usage for SVG:
|
107
|
+
// - xlink:href / xlinkHref --> href (xlink:href was removed from SVG and isn't needed)
|
108
|
+
// - className --> class
|
109
|
+
name = name.replace(/xlink[H:h]/, 'h').replace(/sName$/, 's');
|
110
|
+
} else if (
|
111
|
+
name !== 'href' &&
|
112
|
+
name !== 'list' &&
|
113
|
+
name !== 'form' &&
|
114
|
+
// Default value in browsers is `-1` and an empty string is
|
115
|
+
// cast to `0` instead
|
116
|
+
name !== 'tabIndex' &&
|
117
|
+
name !== 'download' &&
|
118
|
+
name in dom
|
119
|
+
) {
|
120
|
+
try {
|
121
|
+
dom[name] = value == null ? '' : value;
|
122
|
+
// labelled break is 1b smaller here than a return statement (sorry)
|
123
|
+
break o;
|
124
|
+
} catch (e) {}
|
125
|
+
}
|
126
|
+
|
127
|
+
// ARIA-attributes have a different notion of boolean values.
|
128
|
+
// The value `false` is different from the attribute not
|
129
|
+
// existing on the DOM, so we can't remove it. For non-boolean
|
130
|
+
// ARIA-attributes we could treat false as a removal, but the
|
131
|
+
// amount of exceptions would cost us too many bytes. On top of
|
132
|
+
// that other VDOM frameworks also always stringify `false`.
|
133
|
+
|
134
|
+
if (typeof value === 'function') {
|
135
|
+
// never serialize functions as attribute values
|
136
|
+
} else if (
|
137
|
+
value != null &&
|
138
|
+
(value !== false || (name[0] === 'a' && name[1] === 'r'))
|
139
|
+
) {
|
140
|
+
dom.setAttribute(name, value);
|
141
|
+
} else {
|
142
|
+
dom.removeAttribute(name);
|
143
|
+
}
|
144
|
+
}
|
145
|
+
}
|
146
|
+
|
147
|
+
/**
|
148
|
+
* Proxy an event to hooked event handlers
|
149
|
+
* @param {Event} e The event object from the browser
|
150
|
+
* @private
|
151
|
+
*/
|
152
|
+
function eventProxy(e) {
|
153
|
+
this._listeners[e.type + false](options.event ? options.event(e) : e);
|
154
|
+
}
|
155
|
+
|
156
|
+
function eventProxyCapture(e) {
|
157
|
+
this._listeners[e.type + true](options.event ? options.event(e) : e);
|
158
|
+
}
|