isomorfeus-preact 10.8.2 → 22.9.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +14 -3
- data/README.md +23 -39
- data/lib/browser/delegate_native.rb +94 -72
- data/lib/browser/document.rb +38 -0
- data/lib/browser/element.rb +160 -176
- data/lib/browser/event.rb +99 -94
- data/lib/browser/history.rb +40 -20
- data/lib/browser/location.rb +59 -0
- data/lib/browser/window.rb +58 -0
- data/lib/data_uri/open_uri.rb +18 -0
- data/lib/data_uri/uri.rb +61 -0
- data/lib/data_uri.rb +4 -0
- data/lib/isomorfeus/preact/config.rb +42 -54
- data/lib/isomorfeus/preact/imports.rb +5 -20
- data/lib/isomorfeus/preact/ssr.rb +34 -0
- data/lib/isomorfeus/preact/thread_local_component_cache.rb +9 -11
- data/lib/isomorfeus/preact/version.rb +5 -0
- data/lib/isomorfeus/preact/view_helper.rb +72 -0
- data/lib/isomorfeus/props/validator.rb +19 -11
- data/lib/isomorfeus/top_level.rb +55 -33
- data/lib/isomorfeus-preact.rb +78 -103
- data/lib/link.rb +52 -0
- data/lib/lucid_app.rb +117 -0
- data/lib/lucid_component.rb +154 -0
- data/lib/nano_css.rb +282 -465
- data/lib/preact/component.rb +222 -0
- data/lib/preact/component_resolution.rb +49 -83
- data/lib/preact/context.rb +68 -0
- data/lib/preact/elements.rb +2 -9
- data/lib/preact/module_component_resolution.rb +50 -0
- data/lib/preact/prop_declaration_mixin.rb +73 -0
- data/lib/preact.rb +1548 -257
- data/lib/redirect.rb +34 -0
- data/lib/route.rb +15 -0
- data/lib/router.rb +145 -0
- data/lib/switch.rb +70 -0
- metadata +42 -309
- data/lib/isomorfeus/preact/memcached_component_cache.rb +0 -19
- data/lib/isomorfeus/preact/redis_component_cache.rb +0 -19
- data/lib/isomorfeus/preact/ssr/history.rb +0 -23
- data/lib/isomorfeus/preact/ssr/render_core.rb +0 -117
- data/lib/isomorfeus/preact/ssr/top_level.rb +0 -37
- data/lib/isomorfeus/preact_view_helper.rb +0 -129
- data/lib/isomorfeus_preact/lucid_app/api.rb +0 -38
- data/lib/isomorfeus_preact/lucid_app/base.rb +0 -7
- data/lib/isomorfeus_preact/lucid_app/mixin.rb +0 -14
- data/lib/isomorfeus_preact/lucid_app/native_component_constructor.rb +0 -101
- data/lib/isomorfeus_preact/lucid_component/api.rb +0 -123
- data/lib/isomorfeus_preact/lucid_component/app_store_proxy.rb +0 -32
- data/lib/isomorfeus_preact/lucid_component/base.rb +0 -7
- data/lib/isomorfeus_preact/lucid_component/class_store_proxy.rb +0 -37
- data/lib/isomorfeus_preact/lucid_component/initializer.rb +0 -9
- data/lib/isomorfeus_preact/lucid_component/mixin.rb +0 -13
- data/lib/isomorfeus_preact/lucid_component/native_component_constructor.rb +0 -87
- data/lib/isomorfeus_preact/lucid_component/styles_wrapper.rb +0 -40
- data/lib/isomorfeus_preact/lucid_func/base.rb +0 -7
- data/lib/isomorfeus_preact/lucid_func/initializer.rb +0 -8
- data/lib/isomorfeus_preact/lucid_func/mixin.rb +0 -10
- data/lib/isomorfeus_preact/lucid_func/native_component_constructor.rb +0 -56
- data/lib/isomorfeus_preact/preact/function_component/api.rb +0 -140
- data/lib/isomorfeus_preact/preact/function_component/base.rb +0 -7
- data/lib/isomorfeus_preact/preact/function_component/initializer.rb +0 -6
- data/lib/isomorfeus_preact/preact/function_component/mixin.rb +0 -8
- data/lib/isomorfeus_preact/preact/function_component/native_component_constructor.rb +0 -47
- data/lib/lucid_app/context.rb +0 -24
- data/lib/lucid_prop_declaration/mixin.rb +0 -126
- data/lib/preact/component/api.rb +0 -137
- data/lib/preact/component/base.rb +0 -7
- data/lib/preact/component/callbacks.rb +0 -111
- data/lib/preact/component/initializer.rb +0 -7
- data/lib/preact/component/mixin.rb +0 -11
- data/lib/preact/component/native_component_constructor.rb +0 -77
- data/lib/preact/context_wrapper.rb +0 -48
- data/lib/preact/native_constant_wrapper.rb +0 -29
- data/lib/preact/option_hooks.rb +0 -98
- data/lib/preact/params.rb +0 -16
- data/lib/preact/props.rb +0 -69
- data/lib/preact/ref.rb +0 -17
- data/lib/preact/state.rb +0 -87
- data/lib/preact/version.rb +0 -3
- data/node_modules/.package-lock.json +0 -38
- data/node_modules/preact/LICENSE +0 -21
- data/node_modules/preact/README.md +0 -188
- data/node_modules/preact/compat/LICENSE +0 -21
- data/node_modules/preact/compat/client.js +0 -19
- data/node_modules/preact/compat/client.mjs +0 -17
- data/node_modules/preact/compat/dist/compat.js +0 -2
- data/node_modules/preact/compat/dist/compat.js.map +0 -1
- data/node_modules/preact/compat/dist/compat.mjs +0 -2
- data/node_modules/preact/compat/dist/compat.module.js +0 -2
- data/node_modules/preact/compat/dist/compat.module.js.map +0 -1
- data/node_modules/preact/compat/dist/compat.umd.js +0 -2
- data/node_modules/preact/compat/dist/compat.umd.js.map +0 -1
- data/node_modules/preact/compat/jsx-dev-runtime.js +0 -3
- data/node_modules/preact/compat/jsx-dev-runtime.mjs +0 -3
- data/node_modules/preact/compat/jsx-runtime.js +0 -3
- data/node_modules/preact/compat/jsx-runtime.mjs +0 -3
- data/node_modules/preact/compat/package.json +0 -49
- data/node_modules/preact/compat/scheduler.js +0 -15
- data/node_modules/preact/compat/scheduler.mjs +0 -23
- data/node_modules/preact/compat/server.browser.js +0 -4
- data/node_modules/preact/compat/server.js +0 -15
- data/node_modules/preact/compat/server.mjs +0 -4
- data/node_modules/preact/compat/src/Children.js +0 -21
- data/node_modules/preact/compat/src/PureComponent.js +0 -15
- data/node_modules/preact/compat/src/forwardRef.js +0 -44
- data/node_modules/preact/compat/src/index.d.ts +0 -155
- data/node_modules/preact/compat/src/index.js +0 -187
- data/node_modules/preact/compat/src/internal.d.ts +0 -47
- data/node_modules/preact/compat/src/memo.js +0 -34
- data/node_modules/preact/compat/src/portals.js +0 -82
- data/node_modules/preact/compat/src/render.js +0 -238
- data/node_modules/preact/compat/src/suspense-list.d.ts +0 -14
- data/node_modules/preact/compat/src/suspense-list.js +0 -126
- data/node_modules/preact/compat/src/suspense.d.ts +0 -15
- data/node_modules/preact/compat/src/suspense.js +0 -270
- data/node_modules/preact/compat/src/util.js +0 -28
- data/node_modules/preact/compat/test-utils.js +0 -1
- data/node_modules/preact/debug/LICENSE +0 -21
- data/node_modules/preact/debug/dist/debug.js +0 -2
- data/node_modules/preact/debug/dist/debug.js.map +0 -1
- data/node_modules/preact/debug/dist/debug.mjs +0 -2
- data/node_modules/preact/debug/dist/debug.module.js +0 -2
- data/node_modules/preact/debug/dist/debug.module.js.map +0 -1
- data/node_modules/preact/debug/dist/debug.umd.js +0 -2
- data/node_modules/preact/debug/dist/debug.umd.js.map +0 -1
- data/node_modules/preact/debug/package.json +0 -26
- data/node_modules/preact/debug/src/check-props.js +0 -54
- data/node_modules/preact/debug/src/component-stack.js +0 -146
- data/node_modules/preact/debug/src/constants.js +0 -3
- data/node_modules/preact/debug/src/debug.js +0 -437
- data/node_modules/preact/debug/src/index.js +0 -6
- data/node_modules/preact/debug/src/internal.d.ts +0 -82
- data/node_modules/preact/debug/src/util.js +0 -11
- data/node_modules/preact/devtools/LICENSE +0 -21
- data/node_modules/preact/devtools/dist/devtools.js +0 -2
- data/node_modules/preact/devtools/dist/devtools.js.map +0 -1
- data/node_modules/preact/devtools/dist/devtools.mjs +0 -2
- data/node_modules/preact/devtools/dist/devtools.module.js +0 -2
- data/node_modules/preact/devtools/dist/devtools.module.js.map +0 -1
- data/node_modules/preact/devtools/dist/devtools.umd.js +0 -2
- data/node_modules/preact/devtools/dist/devtools.umd.js.map +0 -1
- data/node_modules/preact/devtools/package.json +0 -25
- data/node_modules/preact/devtools/src/devtools.js +0 -10
- data/node_modules/preact/devtools/src/index.d.ts +0 -8
- data/node_modules/preact/devtools/src/index.js +0 -15
- data/node_modules/preact/dist/preact.js +0 -2
- data/node_modules/preact/dist/preact.js.map +0 -1
- data/node_modules/preact/dist/preact.min.js +0 -2
- data/node_modules/preact/dist/preact.min.js.map +0 -1
- data/node_modules/preact/dist/preact.mjs +0 -2
- data/node_modules/preact/dist/preact.module.js +0 -2
- data/node_modules/preact/dist/preact.module.js.map +0 -1
- data/node_modules/preact/dist/preact.umd.js +0 -2
- data/node_modules/preact/dist/preact.umd.js.map +0 -1
- data/node_modules/preact/hooks/LICENSE +0 -21
- data/node_modules/preact/hooks/dist/hooks.js +0 -2
- data/node_modules/preact/hooks/dist/hooks.js.map +0 -1
- data/node_modules/preact/hooks/dist/hooks.mjs +0 -2
- data/node_modules/preact/hooks/dist/hooks.module.js +0 -2
- data/node_modules/preact/hooks/dist/hooks.module.js.map +0 -1
- data/node_modules/preact/hooks/dist/hooks.umd.js +0 -2
- data/node_modules/preact/hooks/dist/hooks.umd.js.map +0 -1
- data/node_modules/preact/hooks/package.json +0 -35
- data/node_modules/preact/hooks/src/index.d.ts +0 -139
- data/node_modules/preact/hooks/src/index.js +0 -417
- data/node_modules/preact/hooks/src/internal.d.ts +0 -78
- data/node_modules/preact/jsx-runtime/LICENSE +0 -21
- data/node_modules/preact/jsx-runtime/dist/jsxRuntime.js +0 -2
- data/node_modules/preact/jsx-runtime/dist/jsxRuntime.js.map +0 -1
- data/node_modules/preact/jsx-runtime/dist/jsxRuntime.mjs +0 -2
- data/node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js +0 -2
- data/node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js.map +0 -1
- data/node_modules/preact/jsx-runtime/dist/jsxRuntime.umd.js +0 -2
- data/node_modules/preact/jsx-runtime/dist/jsxRuntime.umd.js.map +0 -1
- data/node_modules/preact/jsx-runtime/package.json +0 -28
- data/node_modules/preact/jsx-runtime/src/index.d.ts +0 -50
- data/node_modules/preact/jsx-runtime/src/index.js +0 -77
- data/node_modules/preact/package.json +0 -304
- data/node_modules/preact/src/cjs.js +0 -3
- data/node_modules/preact/src/clone-element.js +0 -34
- data/node_modules/preact/src/component.js +0 -225
- data/node_modules/preact/src/constants.js +0 -3
- data/node_modules/preact/src/create-context.js +0 -68
- data/node_modules/preact/src/create-element.js +0 -98
- data/node_modules/preact/src/diff/catch-error.js +0 -40
- data/node_modules/preact/src/diff/children.js +0 -335
- data/node_modules/preact/src/diff/index.js +0 -533
- data/node_modules/preact/src/diff/props.js +0 -158
- data/node_modules/preact/src/index.d.ts +0 -317
- data/node_modules/preact/src/index.js +0 -13
- data/node_modules/preact/src/internal.d.ts +0 -155
- data/node_modules/preact/src/jsx.d.ts +0 -1013
- data/node_modules/preact/src/options.js +0 -16
- data/node_modules/preact/src/render.js +0 -75
- data/node_modules/preact/src/util.js +0 -27
- data/node_modules/preact/test-utils/dist/testUtils.js +0 -2
- data/node_modules/preact/test-utils/dist/testUtils.js.map +0 -1
- data/node_modules/preact/test-utils/dist/testUtils.mjs +0 -2
- data/node_modules/preact/test-utils/dist/testUtils.module.js +0 -2
- data/node_modules/preact/test-utils/dist/testUtils.module.js.map +0 -1
- data/node_modules/preact/test-utils/dist/testUtils.umd.js +0 -2
- data/node_modules/preact/test-utils/dist/testUtils.umd.js.map +0 -1
- data/node_modules/preact/test-utils/package.json +0 -28
- data/node_modules/preact/test-utils/src/index.d.ts +0 -3
- data/node_modules/preact/test-utils/src/index.js +0 -118
- data/node_modules/preact-render-to-string/LICENSE +0 -21
- data/node_modules/preact-render-to-string/README.md +0 -102
- data/node_modules/preact-render-to-string/dist/commonjs.js +0 -2
- data/node_modules/preact-render-to-string/dist/commonjs.js.map +0 -1
- data/node_modules/preact-render-to-string/dist/index.d.ts +0 -16
- data/node_modules/preact-render-to-string/dist/index.js +0 -1
- data/node_modules/preact-render-to-string/dist/index.js.map +0 -1
- data/node_modules/preact-render-to-string/dist/index.mjs +0 -2
- data/node_modules/preact-render-to-string/dist/index.module.js +0 -2
- data/node_modules/preact-render-to-string/dist/index.module.js.map +0 -1
- data/node_modules/preact-render-to-string/dist/jsx-entry.js +0 -2
- data/node_modules/preact-render-to-string/dist/jsx-entry.js.map +0 -1
- data/node_modules/preact-render-to-string/dist/jsx.d.ts +0 -13
- data/node_modules/preact-render-to-string/dist/jsx.js +0 -1
- data/node_modules/preact-render-to-string/dist/jsx.js.map +0 -1
- data/node_modules/preact-render-to-string/dist/jsx.mjs +0 -2
- data/node_modules/preact-render-to-string/dist/jsx.modern.js +0 -2
- data/node_modules/preact-render-to-string/dist/jsx.modern.js.map +0 -1
- data/node_modules/preact-render-to-string/dist/jsx.module.js +0 -2
- data/node_modules/preact-render-to-string/dist/jsx.module.js.map +0 -1
- data/node_modules/preact-render-to-string/dist/preact-render-to-string-tests.d.ts +0 -1
- data/node_modules/preact-render-to-string/jsx.js +0 -1
- data/node_modules/preact-render-to-string/package.json +0 -142
- data/node_modules/preact-render-to-string/src/index.d.ts +0 -16
- data/node_modules/preact-render-to-string/src/index.js +0 -462
- data/node_modules/preact-render-to-string/src/jsx.d.ts +0 -13
- data/node_modules/preact-render-to-string/src/jsx.js +0 -76
- data/node_modules/preact-render-to-string/src/polyfills.js +0 -8
- data/node_modules/preact-render-to-string/src/preact-render-to-string-tests.d.ts +0 -1
- data/node_modules/preact-render-to-string/src/util.js +0 -78
- data/node_modules/preact-render-to-string/typings.json +0 -5
- data/node_modules/pretty-format/.npmignore +0 -3
- data/node_modules/pretty-format/LICENSE.md +0 -15
- data/node_modules/pretty-format/README.md +0 -94
- data/node_modules/pretty-format/index.js +0 -343
- data/node_modules/pretty-format/package.json +0 -26
- data/node_modules/pretty-format/plugins/ReactElement.js +0 -74
- data/node_modules/pretty-format/plugins/ReactTestComponent.js +0 -58
- data/node_modules/pretty-format/printString.js +0 -7
- data/node_modules/wouter-preact/cjs/index.js +0 -180
- data/node_modules/wouter-preact/cjs/matcher.js +0 -72
- data/node_modules/wouter-preact/cjs/package.json +0 -1
- data/node_modules/wouter-preact/cjs/react-deps.js +0 -75
- data/node_modules/wouter-preact/cjs/static-location.js +0 -21
- data/node_modules/wouter-preact/cjs/use-location.js +0 -94
- data/node_modules/wouter-preact/index.d.ts +0 -110
- data/node_modules/wouter-preact/index.js +0 -178
- data/node_modules/wouter-preact/matcher.d.ts +0 -30
- data/node_modules/wouter-preact/matcher.js +0 -66
- data/node_modules/wouter-preact/package.json +0 -33
- data/node_modules/wouter-preact/react-deps.js +0 -15
- data/node_modules/wouter-preact/static-location.d.ts +0 -16
- data/node_modules/wouter-preact/static-location.js +0 -17
- data/node_modules/wouter-preact/use-location.d.ts +0 -43
- data/node_modules/wouter-preact/use-location.js +0 -86
- data/package.json +0 -8
@@ -1,533 +0,0 @@
|
|
1
|
-
import { EMPTY_OBJ } from '../constants';
|
2
|
-
import { Component, getDomSibling } from '../component';
|
3
|
-
import { Fragment } from '../create-element';
|
4
|
-
import { diffChildren } from './children';
|
5
|
-
import { diffProps, setProperty } from './props';
|
6
|
-
import { assign, removeNode, slice } from '../util';
|
7
|
-
import options from '../options';
|
8
|
-
|
9
|
-
/**
|
10
|
-
* Diff two virtual nodes and apply proper changes to the DOM
|
11
|
-
* @param {import('../internal').PreactElement} parentDom The parent of the DOM element
|
12
|
-
* @param {import('../internal').VNode} newVNode The new virtual node
|
13
|
-
* @param {import('../internal').VNode} oldVNode The old virtual node
|
14
|
-
* @param {object} globalContext The current context object. Modified by getChildContext
|
15
|
-
* @param {boolean} isSvg Whether or not this element is an SVG node
|
16
|
-
* @param {Array<import('../internal').PreactElement>} excessDomChildren
|
17
|
-
* @param {Array<import('../internal').Component>} commitQueue List of components
|
18
|
-
* which have callbacks to invoke in commitRoot
|
19
|
-
* @param {import('../internal').PreactElement} oldDom The current attached DOM
|
20
|
-
* element any new dom elements should be placed around. Likely `null` on first
|
21
|
-
* render (except when hydrating). Can be a sibling DOM element when diffing
|
22
|
-
* Fragments that have siblings. In most cases, it starts out as `oldChildren[0]._dom`.
|
23
|
-
* @param {boolean} [isHydrating] Whether or not we are in hydration
|
24
|
-
*/
|
25
|
-
export function diff(
|
26
|
-
parentDom,
|
27
|
-
newVNode,
|
28
|
-
oldVNode,
|
29
|
-
globalContext,
|
30
|
-
isSvg,
|
31
|
-
excessDomChildren,
|
32
|
-
commitQueue,
|
33
|
-
oldDom,
|
34
|
-
isHydrating
|
35
|
-
) {
|
36
|
-
let tmp,
|
37
|
-
newType = newVNode.type;
|
38
|
-
|
39
|
-
// When passing through createElement it assigns the object
|
40
|
-
// constructor as undefined. This to prevent JSON-injection.
|
41
|
-
if (newVNode.constructor !== undefined) return null;
|
42
|
-
|
43
|
-
// If the previous diff bailed out, resume creating/hydrating.
|
44
|
-
if (oldVNode._hydrating != null) {
|
45
|
-
isHydrating = oldVNode._hydrating;
|
46
|
-
oldDom = newVNode._dom = oldVNode._dom;
|
47
|
-
// if we resume, we want the tree to be "unlocked"
|
48
|
-
newVNode._hydrating = null;
|
49
|
-
excessDomChildren = [oldDom];
|
50
|
-
}
|
51
|
-
|
52
|
-
if ((tmp = options._diff)) tmp(newVNode);
|
53
|
-
|
54
|
-
try {
|
55
|
-
outer: if (typeof newType == 'function') {
|
56
|
-
let c, isNew, oldProps, oldState, snapshot, clearProcessingException;
|
57
|
-
let newProps = newVNode.props;
|
58
|
-
|
59
|
-
// Necessary for createContext api. Setting this property will pass
|
60
|
-
// the context value as `this.context` just for this component.
|
61
|
-
tmp = newType.contextType;
|
62
|
-
let provider = tmp && globalContext[tmp._id];
|
63
|
-
let componentContext = tmp
|
64
|
-
? provider
|
65
|
-
? provider.props.value
|
66
|
-
: tmp._defaultValue
|
67
|
-
: globalContext;
|
68
|
-
|
69
|
-
// Get component and set it to `c`
|
70
|
-
if (oldVNode._component) {
|
71
|
-
c = newVNode._component = oldVNode._component;
|
72
|
-
clearProcessingException = c._processingException = c._pendingError;
|
73
|
-
} else {
|
74
|
-
// Instantiate the new component
|
75
|
-
if ('prototype' in newType && newType.prototype.render) {
|
76
|
-
// @ts-ignore The check above verifies that newType is suppose to be constructed
|
77
|
-
newVNode._component = c = new newType(newProps, componentContext); // eslint-disable-line new-cap
|
78
|
-
} else {
|
79
|
-
// @ts-ignore Trust me, Component implements the interface we want
|
80
|
-
newVNode._component = c = new Component(newProps, componentContext);
|
81
|
-
c.constructor = newType;
|
82
|
-
c.render = doRender;
|
83
|
-
}
|
84
|
-
if (provider) provider.sub(c);
|
85
|
-
|
86
|
-
c.props = newProps;
|
87
|
-
if (!c.state) c.state = {};
|
88
|
-
c.context = componentContext;
|
89
|
-
c._globalContext = globalContext;
|
90
|
-
isNew = c._dirty = true;
|
91
|
-
c._renderCallbacks = [];
|
92
|
-
}
|
93
|
-
|
94
|
-
// Invoke getDerivedStateFromProps
|
95
|
-
if (c._nextState == null) {
|
96
|
-
c._nextState = c.state;
|
97
|
-
}
|
98
|
-
if (newType.getDerivedStateFromProps != null) {
|
99
|
-
if (c._nextState == c.state) {
|
100
|
-
c._nextState = assign({}, c._nextState);
|
101
|
-
}
|
102
|
-
|
103
|
-
assign(
|
104
|
-
c._nextState,
|
105
|
-
newType.getDerivedStateFromProps(newProps, c._nextState)
|
106
|
-
);
|
107
|
-
}
|
108
|
-
|
109
|
-
oldProps = c.props;
|
110
|
-
oldState = c.state;
|
111
|
-
|
112
|
-
// Invoke pre-render lifecycle methods
|
113
|
-
if (isNew) {
|
114
|
-
if (
|
115
|
-
newType.getDerivedStateFromProps == null &&
|
116
|
-
c.componentWillMount != null
|
117
|
-
) {
|
118
|
-
c.componentWillMount();
|
119
|
-
}
|
120
|
-
|
121
|
-
if (c.componentDidMount != null) {
|
122
|
-
c._renderCallbacks.push(c.componentDidMount);
|
123
|
-
}
|
124
|
-
} else {
|
125
|
-
if (
|
126
|
-
newType.getDerivedStateFromProps == null &&
|
127
|
-
newProps !== oldProps &&
|
128
|
-
c.componentWillReceiveProps != null
|
129
|
-
) {
|
130
|
-
c.componentWillReceiveProps(newProps, componentContext);
|
131
|
-
}
|
132
|
-
|
133
|
-
if (
|
134
|
-
(!c._force &&
|
135
|
-
c.shouldComponentUpdate != null &&
|
136
|
-
c.shouldComponentUpdate(
|
137
|
-
newProps,
|
138
|
-
c._nextState,
|
139
|
-
componentContext
|
140
|
-
) === false) ||
|
141
|
-
newVNode._original === oldVNode._original
|
142
|
-
) {
|
143
|
-
c.props = newProps;
|
144
|
-
c.state = c._nextState;
|
145
|
-
// More info about this here: https://gist.github.com/JoviDeCroock/bec5f2ce93544d2e6070ef8e0036e4e8
|
146
|
-
if (newVNode._original !== oldVNode._original) c._dirty = false;
|
147
|
-
c._vnode = newVNode;
|
148
|
-
newVNode._dom = oldVNode._dom;
|
149
|
-
newVNode._children = oldVNode._children;
|
150
|
-
newVNode._children.forEach(vnode => {
|
151
|
-
if (vnode) vnode._parent = newVNode;
|
152
|
-
});
|
153
|
-
if (c._renderCallbacks.length) {
|
154
|
-
commitQueue.push(c);
|
155
|
-
}
|
156
|
-
|
157
|
-
break outer;
|
158
|
-
}
|
159
|
-
|
160
|
-
if (c.componentWillUpdate != null) {
|
161
|
-
c.componentWillUpdate(newProps, c._nextState, componentContext);
|
162
|
-
}
|
163
|
-
|
164
|
-
if (c.componentDidUpdate != null) {
|
165
|
-
c._renderCallbacks.push(() => {
|
166
|
-
c.componentDidUpdate(oldProps, oldState, snapshot);
|
167
|
-
});
|
168
|
-
}
|
169
|
-
}
|
170
|
-
|
171
|
-
c.context = componentContext;
|
172
|
-
c.props = newProps;
|
173
|
-
c._vnode = newVNode;
|
174
|
-
c._parentDom = parentDom;
|
175
|
-
|
176
|
-
let renderHook = options._render,
|
177
|
-
count = 0;
|
178
|
-
if ('prototype' in newType && newType.prototype.render) {
|
179
|
-
c.state = c._nextState;
|
180
|
-
c._dirty = false;
|
181
|
-
|
182
|
-
if (renderHook) renderHook(newVNode);
|
183
|
-
|
184
|
-
tmp = c.render(c.props, c.state, c.context);
|
185
|
-
} else {
|
186
|
-
do {
|
187
|
-
c._dirty = false;
|
188
|
-
if (renderHook) renderHook(newVNode);
|
189
|
-
|
190
|
-
tmp = c.render(c.props, c.state, c.context);
|
191
|
-
|
192
|
-
// Handle setState called in render, see #2553
|
193
|
-
c.state = c._nextState;
|
194
|
-
} while (c._dirty && ++count < 25);
|
195
|
-
}
|
196
|
-
|
197
|
-
// Handle setState called in render, see #2553
|
198
|
-
c.state = c._nextState;
|
199
|
-
|
200
|
-
if (c.getChildContext != null) {
|
201
|
-
globalContext = assign(assign({}, globalContext), c.getChildContext());
|
202
|
-
}
|
203
|
-
|
204
|
-
if (!isNew && c.getSnapshotBeforeUpdate != null) {
|
205
|
-
snapshot = c.getSnapshotBeforeUpdate(oldProps, oldState);
|
206
|
-
}
|
207
|
-
|
208
|
-
let isTopLevelFragment =
|
209
|
-
tmp != null && tmp.type === Fragment && tmp.key == null;
|
210
|
-
let renderResult = isTopLevelFragment ? tmp.props.children : tmp;
|
211
|
-
|
212
|
-
diffChildren(
|
213
|
-
parentDom,
|
214
|
-
Array.isArray(renderResult) ? renderResult : [renderResult],
|
215
|
-
newVNode,
|
216
|
-
oldVNode,
|
217
|
-
globalContext,
|
218
|
-
isSvg,
|
219
|
-
excessDomChildren,
|
220
|
-
commitQueue,
|
221
|
-
oldDom,
|
222
|
-
isHydrating
|
223
|
-
);
|
224
|
-
|
225
|
-
c.base = newVNode._dom;
|
226
|
-
|
227
|
-
// We successfully rendered this VNode, unset any stored hydration/bailout state:
|
228
|
-
newVNode._hydrating = null;
|
229
|
-
|
230
|
-
if (c._renderCallbacks.length) {
|
231
|
-
commitQueue.push(c);
|
232
|
-
}
|
233
|
-
|
234
|
-
if (clearProcessingException) {
|
235
|
-
c._pendingError = c._processingException = null;
|
236
|
-
}
|
237
|
-
|
238
|
-
c._force = false;
|
239
|
-
} else if (
|
240
|
-
excessDomChildren == null &&
|
241
|
-
newVNode._original === oldVNode._original
|
242
|
-
) {
|
243
|
-
newVNode._children = oldVNode._children;
|
244
|
-
newVNode._dom = oldVNode._dom;
|
245
|
-
} else {
|
246
|
-
newVNode._dom = diffElementNodes(
|
247
|
-
oldVNode._dom,
|
248
|
-
newVNode,
|
249
|
-
oldVNode,
|
250
|
-
globalContext,
|
251
|
-
isSvg,
|
252
|
-
excessDomChildren,
|
253
|
-
commitQueue,
|
254
|
-
isHydrating
|
255
|
-
);
|
256
|
-
}
|
257
|
-
|
258
|
-
if ((tmp = options.diffed)) tmp(newVNode);
|
259
|
-
} catch (e) {
|
260
|
-
newVNode._original = null;
|
261
|
-
// if hydrating or creating initial tree, bailout preserves DOM:
|
262
|
-
if (isHydrating || excessDomChildren != null) {
|
263
|
-
newVNode._dom = oldDom;
|
264
|
-
newVNode._hydrating = !!isHydrating;
|
265
|
-
excessDomChildren[excessDomChildren.indexOf(oldDom)] = null;
|
266
|
-
// ^ could possibly be simplified to:
|
267
|
-
// excessDomChildren.length = 0;
|
268
|
-
}
|
269
|
-
options._catchError(e, newVNode, oldVNode);
|
270
|
-
}
|
271
|
-
}
|
272
|
-
|
273
|
-
/**
|
274
|
-
* @param {Array<import('../internal').Component>} commitQueue List of components
|
275
|
-
* which have callbacks to invoke in commitRoot
|
276
|
-
* @param {import('../internal').VNode} root
|
277
|
-
*/
|
278
|
-
export function commitRoot(commitQueue, root) {
|
279
|
-
if (options._commit) options._commit(root, commitQueue);
|
280
|
-
|
281
|
-
commitQueue.some(c => {
|
282
|
-
try {
|
283
|
-
// @ts-ignore Reuse the commitQueue variable here so the type changes
|
284
|
-
commitQueue = c._renderCallbacks;
|
285
|
-
c._renderCallbacks = [];
|
286
|
-
commitQueue.some(cb => {
|
287
|
-
// @ts-ignore See above ts-ignore on commitQueue
|
288
|
-
cb.call(c);
|
289
|
-
});
|
290
|
-
} catch (e) {
|
291
|
-
options._catchError(e, c._vnode);
|
292
|
-
}
|
293
|
-
});
|
294
|
-
}
|
295
|
-
|
296
|
-
/**
|
297
|
-
* Diff two virtual nodes representing DOM element
|
298
|
-
* @param {import('../internal').PreactElement} dom The DOM element representing
|
299
|
-
* the virtual nodes being diffed
|
300
|
-
* @param {import('../internal').VNode} newVNode The new virtual node
|
301
|
-
* @param {import('../internal').VNode} oldVNode The old virtual node
|
302
|
-
* @param {object} globalContext The current context object
|
303
|
-
* @param {boolean} isSvg Whether or not this DOM node is an SVG node
|
304
|
-
* @param {*} excessDomChildren
|
305
|
-
* @param {Array<import('../internal').Component>} commitQueue List of components
|
306
|
-
* which have callbacks to invoke in commitRoot
|
307
|
-
* @param {boolean} isHydrating Whether or not we are in hydration
|
308
|
-
* @returns {import('../internal').PreactElement}
|
309
|
-
*/
|
310
|
-
function diffElementNodes(
|
311
|
-
dom,
|
312
|
-
newVNode,
|
313
|
-
oldVNode,
|
314
|
-
globalContext,
|
315
|
-
isSvg,
|
316
|
-
excessDomChildren,
|
317
|
-
commitQueue,
|
318
|
-
isHydrating
|
319
|
-
) {
|
320
|
-
let oldProps = oldVNode.props;
|
321
|
-
let newProps = newVNode.props;
|
322
|
-
let nodeType = newVNode.type;
|
323
|
-
let i = 0;
|
324
|
-
|
325
|
-
// Tracks entering and exiting SVG namespace when descending through the tree.
|
326
|
-
if (nodeType === 'svg') isSvg = true;
|
327
|
-
|
328
|
-
if (excessDomChildren != null) {
|
329
|
-
for (; i < excessDomChildren.length; i++) {
|
330
|
-
const child = excessDomChildren[i];
|
331
|
-
|
332
|
-
// if newVNode matches an element in excessDomChildren or the `dom`
|
333
|
-
// argument matches an element in excessDomChildren, remove it from
|
334
|
-
// excessDomChildren so it isn't later removed in diffChildren
|
335
|
-
if (
|
336
|
-
child &&
|
337
|
-
'setAttribute' in child === !!nodeType &&
|
338
|
-
(nodeType ? child.localName === nodeType : child.nodeType === 3)
|
339
|
-
) {
|
340
|
-
dom = child;
|
341
|
-
excessDomChildren[i] = null;
|
342
|
-
break;
|
343
|
-
}
|
344
|
-
}
|
345
|
-
}
|
346
|
-
|
347
|
-
if (dom == null) {
|
348
|
-
if (nodeType === null) {
|
349
|
-
// @ts-ignore createTextNode returns Text, we expect PreactElement
|
350
|
-
return document.createTextNode(newProps);
|
351
|
-
}
|
352
|
-
|
353
|
-
if (isSvg) {
|
354
|
-
dom = document.createElementNS(
|
355
|
-
'http://www.w3.org/2000/svg',
|
356
|
-
// @ts-ignore We know `newVNode.type` is a string
|
357
|
-
nodeType
|
358
|
-
);
|
359
|
-
} else {
|
360
|
-
dom = document.createElement(
|
361
|
-
// @ts-ignore We know `newVNode.type` is a string
|
362
|
-
nodeType,
|
363
|
-
newProps.is && newProps
|
364
|
-
);
|
365
|
-
}
|
366
|
-
|
367
|
-
// we created a new parent, so none of the previously attached children can be reused:
|
368
|
-
excessDomChildren = null;
|
369
|
-
// we are creating a new node, so we can assume this is a new subtree (in case we are hydrating), this deopts the hydrate
|
370
|
-
isHydrating = false;
|
371
|
-
}
|
372
|
-
|
373
|
-
if (nodeType === null) {
|
374
|
-
// During hydration, we still have to split merged text from SSR'd HTML.
|
375
|
-
if (oldProps !== newProps && (!isHydrating || dom.data !== newProps)) {
|
376
|
-
dom.data = newProps;
|
377
|
-
}
|
378
|
-
} else {
|
379
|
-
// If excessDomChildren was not null, repopulate it with the current element's children:
|
380
|
-
excessDomChildren = excessDomChildren && slice.call(dom.childNodes);
|
381
|
-
|
382
|
-
oldProps = oldVNode.props || EMPTY_OBJ;
|
383
|
-
|
384
|
-
let oldHtml = oldProps.dangerouslySetInnerHTML;
|
385
|
-
let newHtml = newProps.dangerouslySetInnerHTML;
|
386
|
-
|
387
|
-
// During hydration, props are not diffed at all (including dangerouslySetInnerHTML)
|
388
|
-
// @TODO we should warn in debug mode when props don't match here.
|
389
|
-
if (!isHydrating) {
|
390
|
-
// But, if we are in a situation where we are using existing DOM (e.g. replaceNode)
|
391
|
-
// we should read the existing DOM attributes to diff them
|
392
|
-
if (excessDomChildren != null) {
|
393
|
-
oldProps = {};
|
394
|
-
for (i = 0; i < dom.attributes.length; i++) {
|
395
|
-
oldProps[dom.attributes[i].name] = dom.attributes[i].value;
|
396
|
-
}
|
397
|
-
}
|
398
|
-
|
399
|
-
if (newHtml || oldHtml) {
|
400
|
-
// Avoid re-applying the same '__html' if it did not changed between re-render
|
401
|
-
if (
|
402
|
-
!newHtml ||
|
403
|
-
((!oldHtml || newHtml.__html != oldHtml.__html) &&
|
404
|
-
newHtml.__html !== dom.innerHTML)
|
405
|
-
) {
|
406
|
-
dom.innerHTML = (newHtml && newHtml.__html) || '';
|
407
|
-
}
|
408
|
-
}
|
409
|
-
}
|
410
|
-
|
411
|
-
diffProps(dom, newProps, oldProps, isSvg, isHydrating);
|
412
|
-
|
413
|
-
// If the new vnode didn't have dangerouslySetInnerHTML, diff its children
|
414
|
-
if (newHtml) {
|
415
|
-
newVNode._children = [];
|
416
|
-
} else {
|
417
|
-
i = newVNode.props.children;
|
418
|
-
diffChildren(
|
419
|
-
dom,
|
420
|
-
Array.isArray(i) ? i : [i],
|
421
|
-
newVNode,
|
422
|
-
oldVNode,
|
423
|
-
globalContext,
|
424
|
-
isSvg && nodeType !== 'foreignObject',
|
425
|
-
excessDomChildren,
|
426
|
-
commitQueue,
|
427
|
-
excessDomChildren
|
428
|
-
? excessDomChildren[0]
|
429
|
-
: oldVNode._children && getDomSibling(oldVNode, 0),
|
430
|
-
isHydrating
|
431
|
-
);
|
432
|
-
|
433
|
-
// Remove children that are not part of any vnode.
|
434
|
-
if (excessDomChildren != null) {
|
435
|
-
for (i = excessDomChildren.length; i--; ) {
|
436
|
-
if (excessDomChildren[i] != null) removeNode(excessDomChildren[i]);
|
437
|
-
}
|
438
|
-
}
|
439
|
-
}
|
440
|
-
|
441
|
-
// (as above, don't diff props during hydration)
|
442
|
-
if (!isHydrating) {
|
443
|
-
if (
|
444
|
-
'value' in newProps &&
|
445
|
-
(i = newProps.value) !== undefined &&
|
446
|
-
// #2756 For the <progress>-element the initial value is 0,
|
447
|
-
// despite the attribute not being present. When the attribute
|
448
|
-
// is missing the progress bar is treated as indeterminate.
|
449
|
-
// To fix that we'll always update it when it is 0 for progress elements
|
450
|
-
(i !== dom.value ||
|
451
|
-
(nodeType === 'progress' && !i) ||
|
452
|
-
// This is only for IE 11 to fix <select> value not being updated.
|
453
|
-
// To avoid a stale select value we need to set the option.value
|
454
|
-
// again, which triggers IE11 to re-evaluate the select value
|
455
|
-
(nodeType === 'option' && i !== oldProps.value))
|
456
|
-
) {
|
457
|
-
setProperty(dom, 'value', i, oldProps.value, false);
|
458
|
-
}
|
459
|
-
if (
|
460
|
-
'checked' in newProps &&
|
461
|
-
(i = newProps.checked) !== undefined &&
|
462
|
-
i !== dom.checked
|
463
|
-
) {
|
464
|
-
setProperty(dom, 'checked', i, oldProps.checked, false);
|
465
|
-
}
|
466
|
-
}
|
467
|
-
}
|
468
|
-
|
469
|
-
return dom;
|
470
|
-
}
|
471
|
-
|
472
|
-
/**
|
473
|
-
* Invoke or update a ref, depending on whether it is a function or object ref.
|
474
|
-
* @param {object|function} ref
|
475
|
-
* @param {any} value
|
476
|
-
* @param {import('../internal').VNode} vnode
|
477
|
-
*/
|
478
|
-
export function applyRef(ref, value, vnode) {
|
479
|
-
try {
|
480
|
-
if (typeof ref == 'function') ref(value);
|
481
|
-
else ref.current = value;
|
482
|
-
} catch (e) {
|
483
|
-
options._catchError(e, vnode);
|
484
|
-
}
|
485
|
-
}
|
486
|
-
|
487
|
-
/**
|
488
|
-
* Unmount a virtual node from the tree and apply DOM changes
|
489
|
-
* @param {import('../internal').VNode} vnode The virtual node to unmount
|
490
|
-
* @param {import('../internal').VNode} parentVNode The parent of the VNode that
|
491
|
-
* initiated the unmount
|
492
|
-
* @param {boolean} [skipRemove] Flag that indicates that a parent node of the
|
493
|
-
* current element is already detached from the DOM.
|
494
|
-
*/
|
495
|
-
export function unmount(vnode, parentVNode, skipRemove) {
|
496
|
-
let r;
|
497
|
-
if (options.unmount) options.unmount(vnode);
|
498
|
-
|
499
|
-
if ((r = vnode.ref)) {
|
500
|
-
if (!r.current || r.current === vnode._dom) applyRef(r, null, parentVNode);
|
501
|
-
}
|
502
|
-
|
503
|
-
if ((r = vnode._component) != null) {
|
504
|
-
if (r.componentWillUnmount) {
|
505
|
-
try {
|
506
|
-
r.componentWillUnmount();
|
507
|
-
} catch (e) {
|
508
|
-
options._catchError(e, parentVNode);
|
509
|
-
}
|
510
|
-
}
|
511
|
-
|
512
|
-
r.base = r._parentDom = null;
|
513
|
-
}
|
514
|
-
|
515
|
-
if ((r = vnode._children)) {
|
516
|
-
for (let i = 0; i < r.length; i++) {
|
517
|
-
if (r[i]) {
|
518
|
-
unmount(r[i], parentVNode, typeof vnode.type != 'function');
|
519
|
-
}
|
520
|
-
}
|
521
|
-
}
|
522
|
-
|
523
|
-
if (!skipRemove && vnode._dom != null) removeNode(vnode._dom);
|
524
|
-
|
525
|
-
// Must be set to `undefined` to properly clean up `_nextDom`
|
526
|
-
// for which `null` is a valid value. See comment in `create-element.js`
|
527
|
-
vnode._dom = vnode._nextDom = undefined;
|
528
|
-
}
|
529
|
-
|
530
|
-
/** The `.render()` method for a PFC backing instance. */
|
531
|
-
function doRender(props, state, context) {
|
532
|
-
return this.constructor(props, context);
|
533
|
-
}
|
@@ -1,158 +0,0 @@
|
|
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
|
-
}
|