@symbo.ls/element 3.14.3 → 3.14.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/dist/cjs/index.cjs +1 -0
- package/dist/cjs/src/cache.cjs +1 -0
- package/dist/cjs/src/create.cjs +6 -0
- package/dist/cjs/src/delegate.cjs +1 -0
- package/dist/cjs/src/dispose.cjs +1 -0
- package/dist/cjs/src/extends.cjs +1 -0
- package/dist/cjs/src/index.cjs +1 -0
- package/dist/cjs/src/methods.cjs +1 -0
- package/dist/cjs/src/registry.cjs +1 -0
- package/dist/cjs/src/update.cjs +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/src/cache.js +1 -0
- package/dist/esm/src/create.js +6 -0
- package/dist/esm/src/delegate.js +1 -0
- package/dist/esm/src/dispose.js +1 -0
- package/dist/esm/src/extends.js +1 -0
- package/dist/esm/src/index.js +1 -0
- package/dist/esm/src/methods.js +1 -0
- package/dist/esm/src/registry.js +1 -0
- package/dist/esm/src/update.js +1 -0
- package/package.json +29 -8
- package/index.js +0 -1
- package/src/cache.js +0 -124
- package/src/create.js +0 -1987
- package/src/delegate.js +0 -163
- package/src/dispose.js +0 -76
- package/src/extends.js +0 -123
- package/src/index.js +0 -8
- package/src/methods.js +0 -271
- package/src/registry.js +0 -79
- package/src/update.js +0 -132
package/src/registry.js
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
// REGISTRY defines all framework-reserved property keys.
|
|
4
|
-
// Any key NOT in this set that starts with uppercase is treated as a child element.
|
|
5
|
-
|
|
6
|
-
export const REGISTRY = new Set([
|
|
7
|
-
// Extends/Inheritance
|
|
8
|
-
'extends',
|
|
9
|
-
// Children/Content
|
|
10
|
-
'children', 'content',
|
|
11
|
-
'childExtends',
|
|
12
|
-
'childExtendsRecursive',
|
|
13
|
-
'childProps', 'inheritParentProps',
|
|
14
|
-
// State
|
|
15
|
-
'state', 'if',
|
|
16
|
-
// Define
|
|
17
|
-
'define', 'deps',
|
|
18
|
-
// DOM
|
|
19
|
-
'tag', 'attr', 'style', 'text', 'html', 'value',
|
|
20
|
-
'data', 'classlist', 'class',
|
|
21
|
-
// Scope/Context
|
|
22
|
-
'scope', 'root', 'context',
|
|
23
|
-
// Routing/Fetching
|
|
24
|
-
'$router', 'routes', 'fetch',
|
|
25
|
-
// Meta
|
|
26
|
-
'variables', 'query', 'key',
|
|
27
|
-
'component', 'preventContentUpdate',
|
|
28
|
-
'preventContentRecreate',
|
|
29
|
-
// Internal
|
|
30
|
-
'__name', '__ref', '__hash', '__text',
|
|
31
|
-
'parent', 'node'
|
|
32
|
-
])
|
|
33
|
-
|
|
34
|
-
// Mixin handlers - these get special processing during create/update
|
|
35
|
-
export const MIXINS = {
|
|
36
|
-
text: 'text',
|
|
37
|
-
html: 'html',
|
|
38
|
-
style: 'style',
|
|
39
|
-
attr: 'attr',
|
|
40
|
-
data: 'data',
|
|
41
|
-
classlist: 'classlist',
|
|
42
|
-
state: 'state',
|
|
43
|
-
scope: 'scope'
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// Events that are lifecycle events (not DOM events)
|
|
47
|
-
export const LIFECYCLE_EVENTS = new Set([
|
|
48
|
-
'start', 'init', 'complete', 'attachNode',
|
|
49
|
-
'stateInit', 'stateCreated',
|
|
50
|
-
'beforeUpdate', 'update', 'afterUpdate',
|
|
51
|
-
'beforeClassAssign', 'lazyLoad',
|
|
52
|
-
'render', 'renderRouter', 'done', 'create', 'frame',
|
|
53
|
-
'startUpdate', 'stateUpdate', 'beforeStateUpdate',
|
|
54
|
-
'initInspect', 'initSync', 'error',
|
|
55
|
-
'beforeRemove', 'remove'
|
|
56
|
-
])
|
|
57
|
-
|
|
58
|
-
// DOM events that block scroll performance unless registered `{ passive: true }`.
|
|
59
|
-
// Chrome logs a "Added non-passive event listener to a scroll-blocking" warning
|
|
60
|
-
// for each non-passive listener on these.
|
|
61
|
-
export const PASSIVE_EVENTS = new Set([
|
|
62
|
-
'wheel', 'mousewheel',
|
|
63
|
-
'touchstart', 'touchmove', 'touchend', 'touchcancel'
|
|
64
|
-
])
|
|
65
|
-
|
|
66
|
-
// DOM events that should be delegated
|
|
67
|
-
export const DELEGATED_EVENTS = new Set([
|
|
68
|
-
'click', 'dblclick', 'mousedown', 'mouseup', 'mousemove',
|
|
69
|
-
'mouseenter', 'mouseleave', 'mouseover', 'mouseout',
|
|
70
|
-
'pointerdown', 'pointerup', 'pointermove',
|
|
71
|
-
'pointerenter', 'pointerleave', 'pointerover', 'pointerout',
|
|
72
|
-
'touchstart', 'touchend', 'touchmove',
|
|
73
|
-
'keydown', 'keyup', 'keypress',
|
|
74
|
-
'input', 'change', 'submit', 'reset',
|
|
75
|
-
'focus', 'blur', 'focusin', 'focusout',
|
|
76
|
-
'scroll', 'wheel',
|
|
77
|
-
'contextmenu', 'drag', 'dragstart', 'dragend',
|
|
78
|
-
'dragenter', 'dragleave', 'dragover', 'drop'
|
|
79
|
-
])
|
package/src/update.js
DELETED
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
import { batch, isStore } from '@symbo.ls/signal'
|
|
4
|
-
import { REGISTRY } from './registry.js'
|
|
5
|
-
import { create } from './create.js'
|
|
6
|
-
import { runPluginHook } from '@symbo.ls/utils/function.js'
|
|
7
|
-
|
|
8
|
-
export function update(params = {}, opts = {}) {
|
|
9
|
-
const element = this
|
|
10
|
-
const ref = element.__ref
|
|
11
|
-
if (!ref) return
|
|
12
|
-
|
|
13
|
-
// Normalize string/number shorthand
|
|
14
|
-
if (typeof params === 'string' || typeof params === 'number') {
|
|
15
|
-
params = { text: params }
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// Fire onBeforeUpdate (v3 syntax — directly on element)
|
|
19
|
-
if (!opts.preventListeners && typeof element.onBeforeUpdate === 'function') {
|
|
20
|
-
const result = element.onBeforeUpdate(element, element.state, element.context, opts)
|
|
21
|
-
if (result === false) return element
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
batch(() => {
|
|
25
|
-
// Update state if provided
|
|
26
|
-
if (params.state && isStore(element.state)) {
|
|
27
|
-
element.state.update(params.state)
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// Update text
|
|
31
|
-
if (params.text !== undefined) {
|
|
32
|
-
element.text = params.text
|
|
33
|
-
if (!ref.__exec.text && element.node) {
|
|
34
|
-
if (element.tag === 'string') {
|
|
35
|
-
element.node.nodeValue = params.text ?? ''
|
|
36
|
-
} else {
|
|
37
|
-
element.node.textContent = params.text ?? ''
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// Update html
|
|
43
|
-
if (params.html !== undefined) {
|
|
44
|
-
element.html = params.html
|
|
45
|
-
if (!ref.__exec.html && element.node) {
|
|
46
|
-
element.node.innerHTML = params.html
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// Update style — mirrors applyStyles in create.js: write via setProperty
|
|
51
|
-
// with `important` priority so cascade resolves to the inline value
|
|
52
|
-
// even when the element carries atomic CSS classes for sibling static
|
|
53
|
-
// props. Plain `node.style[prop] = val` writes don't invalidate the
|
|
54
|
-
// cached cascade when the first-paint resolved to a different value.
|
|
55
|
-
if (params.style && element.node?.style) {
|
|
56
|
-
if (!ref.__exec.style) {
|
|
57
|
-
for (const prop in params.style) {
|
|
58
|
-
const val = params.style[prop]
|
|
59
|
-
if (val == null) continue
|
|
60
|
-
const cssProp = prop.replace(/[A-Z]/g, m => '-' + m.toLowerCase())
|
|
61
|
-
const str = String(val).replace(/\s*!important\s*$/, '')
|
|
62
|
-
element.node.style.setProperty(cssProp, str, 'important')
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
if (!element.style) element.style = {}
|
|
66
|
-
Object.assign(element.style, params.style)
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
if (params.attr && element.node?.setAttribute) {
|
|
70
|
-
for (const key in params.attr) {
|
|
71
|
-
const val = params.attr[key]
|
|
72
|
-
if (val == null || val === false) {
|
|
73
|
-
element.node.removeAttribute(key)
|
|
74
|
-
} else if (typeof val !== 'function' && typeof val !== 'object') {
|
|
75
|
-
element.node.setAttribute(key, val === true ? '' : val)
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
if (!element.attr) element.attr = {}
|
|
79
|
-
Object.assign(element.attr, params.attr)
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
if (params.data && element.node?.dataset) {
|
|
83
|
-
for (const key in params.data) {
|
|
84
|
-
element.node.dataset[key] = params.data[key]
|
|
85
|
-
}
|
|
86
|
-
if (!element.data) element.data = {}
|
|
87
|
-
Object.assign(element.data, params.data)
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
// Handle child element updates and property changes
|
|
91
|
-
for (const param in params) {
|
|
92
|
-
if (REGISTRY.has(param)) continue
|
|
93
|
-
if (param === 'state') continue
|
|
94
|
-
|
|
95
|
-
const childParams = params[param]
|
|
96
|
-
const child = element[param]
|
|
97
|
-
|
|
98
|
-
if (child && child.__ref && typeof child.update === 'function') {
|
|
99
|
-
// Existing child element — recursive update
|
|
100
|
-
child.update(childParams, opts)
|
|
101
|
-
} else if (typeof childParams === 'object' && childParams !== null) {
|
|
102
|
-
const firstChar = param.charCodeAt(0)
|
|
103
|
-
if (firstChar >= 65 && firstChar <= 90) {
|
|
104
|
-
// Uppercase key with object value — create new child element
|
|
105
|
-
create(childParams, element, param, opts)
|
|
106
|
-
}
|
|
107
|
-
} else if (param !== 'text' && param !== 'html' && param !== 'style' && param !== 'attr' && param !== 'data') {
|
|
108
|
-
// Primitive property update (e.g. name, icon, value)
|
|
109
|
-
// Set the property — if it has a reactive effect, the effect will re-run
|
|
110
|
-
element[param] = childParams
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
})
|
|
114
|
-
|
|
115
|
-
// Re-evaluate conditionals (.prop / !prop). Signal-driven predicates already
|
|
116
|
-
// re-fired via createEffect; this catches imperative updates to non-signal
|
|
117
|
-
// predicates (e.g. element.update({ isActive: true }) where isActive is a
|
|
118
|
-
// plain element prop, not a state field).
|
|
119
|
-
if (element.node && ref.__conditionalRunners) {
|
|
120
|
-
for (const run of ref.__conditionalRunners) run()
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
runPluginHook('update', element)
|
|
124
|
-
|
|
125
|
-
if (!opts.preventListeners && typeof element.onUpdate === 'function') {
|
|
126
|
-
element.onUpdate(element, element.state, element.context, opts)
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
return element
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
export default update
|