@kdujs/runtime-dom-canary
Advanced tools
Comparing version 3.20241118.0 to 3.20241125.0-minor.0
@@ -1,6 +0,1 @@ | ||
/** | ||
* @kdujs/runtime-dom-canary v3.20241118.0 | ||
* (c) 2021-present NKDuy | ||
* @license MIT | ||
**/ | ||
'use strict'; | ||
@@ -14,3 +9,2 @@ | ||
const svgNS = "http://www.w3.org/2000/svg"; | ||
const mathmlNS = "http://www.w3.org/1998/Math/MathML"; | ||
const doc = typeof document !== "undefined" ? document : null; | ||
@@ -28,4 +22,4 @@ const templateContainer = doc && /* @__PURE__ */ doc.createElement("template"); | ||
}, | ||
createElement: (tag, namespace, is, props) => { | ||
const el = namespace === "svg" ? doc.createElementNS(svgNS, tag) : namespace === "mathml" ? doc.createElementNS(mathmlNS, tag) : doc.createElement(tag, is ? { is } : void 0); | ||
createElement: (tag, isSVG, is, props) => { | ||
const el = isSVG ? doc.createElementNS(svgNS, tag) : doc.createElement(tag, is ? { is } : void 0); | ||
if (tag === "select" && props && props.multiple != null) { | ||
@@ -54,3 +48,3 @@ el.setAttribute("multiple", props.multiple); | ||
// As long as the user only uses trusted templates, this is safe. | ||
insertStaticContent(content, parent, anchor, namespace, start, end) { | ||
insertStaticContent(content, parent, anchor, isSVG, start, end) { | ||
const before = anchor ? anchor.previousSibling : parent.lastChild; | ||
@@ -60,8 +54,9 @@ if (start && (start === end || start.nextSibling)) { | ||
parent.insertBefore(start.cloneNode(true), anchor); | ||
if (start === end || !(start = start.nextSibling)) break; | ||
if (start === end || !(start = start.nextSibling)) | ||
break; | ||
} | ||
} else { | ||
templateContainer.innerHTML = namespace === "svg" ? `<svg>${content}</svg>` : namespace === "mathml" ? `<math>${content}</math>` : content; | ||
templateContainer.innerHTML = isSVG ? `<svg>${content}</svg>` : content; | ||
const template = templateContainer.content; | ||
if (namespace === "svg" || namespace === "mathml") { | ||
if (isSVG) { | ||
const wrapper = template.firstChild; | ||
@@ -202,4 +197,4 @@ while (wrapper.firstChild) { | ||
addTransitionClass(el, leaveFromClass); | ||
forceReflow(); | ||
addTransitionClass(el, leaveActiveClass); | ||
forceReflow(); | ||
nextFrame(() => { | ||
@@ -346,3 +341,4 @@ if (!el._isLeaving) { | ||
function toMs(s) { | ||
if (s === "auto") return 0; | ||
if (s === "auto") | ||
return 0; | ||
return Number(s.slice(0, -1).replace(",", ".")) * 1e3; | ||
@@ -368,7 +364,6 @@ } | ||
const kShowOriginalDisplay = Symbol("_kod"); | ||
const kShowHidden = Symbol("_ksh"); | ||
const kShowOldKey = Symbol("_kod"); | ||
const kShow = { | ||
beforeMount(el, { value }, { transition }) { | ||
el[kShowOriginalDisplay] = el.style.display === "none" ? "" : el.style.display; | ||
el[kShowOldKey] = el.style.display === "none" ? "" : el.style.display; | ||
if (transition && value) { | ||
@@ -386,3 +381,4 @@ transition.beforeEnter(el); | ||
updated(el, { value, oldValue }, { transition }) { | ||
if (!value === !oldValue) return; | ||
if (!value === !oldValue) | ||
return; | ||
if (transition) { | ||
@@ -406,8 +402,4 @@ if (value) { | ||
}; | ||
{ | ||
kShow.name = "show"; | ||
} | ||
function setDisplay(el, value) { | ||
el.style.display = value ? el[kShowOriginalDisplay] : "none"; | ||
el[kShowHidden] = !value; | ||
el.style.display = value ? el[kShowOldKey] : "none"; | ||
} | ||
@@ -422,44 +414,21 @@ function initKShowForSSR() { | ||
const CSS_VAR_TEXT = Symbol("CSS_VAR_TEXT" ); | ||
function useCssVars(getter) { | ||
return; | ||
} | ||
const displayRE = /(^|;)\s*display\s*:/; | ||
function patchStyle(el, prev, next) { | ||
const style = el.style; | ||
const isCssString = shared.isString(next); | ||
let hasControlledDisplay = false; | ||
if (next && !isCssString) { | ||
if (prev) { | ||
if (!shared.isString(prev)) { | ||
for (const key in prev) { | ||
if (next[key] == null) { | ||
setStyle(style, key, ""); | ||
} | ||
if (prev && !shared.isString(prev)) { | ||
for (const key in prev) { | ||
if (next[key] == null) { | ||
setStyle(style, key, ""); | ||
} | ||
} else { | ||
for (const prevStyle of prev.split(";")) { | ||
const key = prevStyle.slice(0, prevStyle.indexOf(":")).trim(); | ||
if (next[key] == null) { | ||
setStyle(style, key, ""); | ||
} | ||
} | ||
} | ||
} | ||
for (const key in next) { | ||
if (key === "display") { | ||
hasControlledDisplay = true; | ||
} | ||
setStyle(style, key, next[key]); | ||
} | ||
} else { | ||
const currentDisplay = style.display; | ||
if (isCssString) { | ||
if (prev !== next) { | ||
const cssVarText = style[CSS_VAR_TEXT]; | ||
if (cssVarText) { | ||
next += ";" + cssVarText; | ||
} | ||
style.cssText = next; | ||
hasControlledDisplay = displayRE.test(next); | ||
} | ||
@@ -469,7 +438,4 @@ } else if (prev) { | ||
} | ||
} | ||
if (kShowOriginalDisplay in el) { | ||
el[kShowOriginalDisplay] = hasControlledDisplay ? style.display : ""; | ||
if (el[kShowHidden]) { | ||
style.display = "none"; | ||
if (kShowOldKey in el) { | ||
style.display = currentDisplay; | ||
} | ||
@@ -484,3 +450,4 @@ } | ||
} else { | ||
if (val == null) val = ""; | ||
if (val == null) | ||
val = ""; | ||
{ | ||
@@ -559,5 +526,6 @@ if (semicolonRE.test(val)) { | ||
!tag.includes("-")) { | ||
const oldValue = tag === "OPTION" ? el.getAttribute("value") || "" : el.value; | ||
el._value = value; | ||
const oldValue = tag === "OPTION" ? el.getAttribute("value") : el.value; | ||
const newValue = value == null ? "" : value; | ||
if (oldValue !== newValue || !("_value" in el)) { | ||
if (oldValue !== newValue) { | ||
el.value = newValue; | ||
@@ -568,3 +536,2 @@ } | ||
} | ||
el._value = value; | ||
return; | ||
@@ -609,10 +576,7 @@ } | ||
if (nextValue && existingInvoker) { | ||
existingInvoker.value = sanitizeEventValue(nextValue, rawName) ; | ||
existingInvoker.value = nextValue; | ||
} else { | ||
const [name, options] = parseName(rawName); | ||
if (nextValue) { | ||
const invoker = invokers[rawName] = createInvoker( | ||
sanitizeEventValue(nextValue, rawName) , | ||
instance | ||
); | ||
const invoker = invokers[rawName] = createInvoker(nextValue, instance); | ||
addEventListener(el, name, invoker, options); | ||
@@ -660,12 +624,2 @@ } else if (existingInvoker) { | ||
} | ||
function sanitizeEventValue(value, propName) { | ||
if (shared.isFunction(value) || shared.isArray(value)) { | ||
return value; | ||
} | ||
runtimeCore.warn( | ||
`Wrong type passed as event handler to ${propName} - did you forget @ or : in front of your prop? | ||
Expected function or array of functions, received type ${typeof value}.` | ||
); | ||
return shared.NOOP; | ||
} | ||
function patchStopImmediatePropagation(e, value) { | ||
@@ -678,5 +632,3 @@ if (shared.isArray(value)) { | ||
}; | ||
return value.map( | ||
(fn) => (e2) => !e2._stopped && fn && fn(e2) | ||
); | ||
return value.map((fn) => (e2) => !e2._stopped && fn && fn(e2)); | ||
} else { | ||
@@ -687,6 +639,4 @@ return value; | ||
const isNativeOn = (key) => key.charCodeAt(0) === 111 && key.charCodeAt(1) === 110 && // lowercase letter | ||
key.charCodeAt(2) > 96 && key.charCodeAt(2) < 123; | ||
const patchProp = (el, key, prevValue, nextValue, namespace, prevChildren, parentComponent, parentSuspense, unmountChildren) => { | ||
const isSVG = namespace === "svg"; | ||
const nativeOnRE = /^on[a-z]/; | ||
const patchProp = (el, key, prevValue, nextValue, isSVG = false, prevChildren, parentComponent, parentSuspense, unmountChildren) => { | ||
if (key === "class") { | ||
@@ -724,3 +674,3 @@ patchClass(el, nextValue, isSVG); | ||
} | ||
if (key in el && isNativeOn(key) && shared.isFunction(value)) { | ||
if (key in el && nativeOnRE.test(key) && shared.isFunction(value)) { | ||
return true; | ||
@@ -742,9 +692,3 @@ } | ||
} | ||
if (key === "width" || key === "height") { | ||
const tag = el.tagName; | ||
if (tag === "IMG" || tag === "VIDEO" || tag === "CANVAS" || tag === "SOURCE") { | ||
return false; | ||
} | ||
} | ||
if (isNativeOn(key) && shared.isString(value)) { | ||
if (nativeOnRE.test(key) && shared.isString(value)) { | ||
return false; | ||
@@ -812,8 +756,8 @@ } | ||
this._connected = false; | ||
if (this._ob) { | ||
this._ob.disconnect(); | ||
this._ob = null; | ||
} | ||
runtimeCore.nextTick(() => { | ||
if (!this._connected) { | ||
if (this._ob) { | ||
this._ob.disconnect(); | ||
this._ob = null; | ||
} | ||
render(null, this.shadowRoot); | ||
@@ -886,3 +830,3 @@ this._instance = null; | ||
_setAttr(key) { | ||
let value = this.hasAttribute(key) ? this.getAttribute(key) : void 0; | ||
let value = this.getAttribute(key); | ||
const camelKey = shared.camelize(key); | ||
@@ -1000,2 +944,6 @@ if (this._numberProps && this._numberProps[camelKey]) { | ||
function useCssVars(getter) { | ||
return; | ||
} | ||
const positionMap = /* @__PURE__ */ new WeakMap(); | ||
@@ -1054,24 +1002,3 @@ const newPositionMap = /* @__PURE__ */ new WeakMap(); | ||
let tag = rawProps.tag || runtimeCore.Fragment; | ||
prevChildren = []; | ||
if (children) { | ||
for (let i = 0; i < children.length; i++) { | ||
const child = children[i]; | ||
if (child.el && child.el instanceof Element) { | ||
prevChildren.push(child); | ||
runtimeCore.setTransitionHooks( | ||
child, | ||
runtimeCore.resolveTransitionHooks( | ||
child, | ||
cssTransitionProps, | ||
state, | ||
instance | ||
) | ||
); | ||
positionMap.set( | ||
child, | ||
child.el.getBoundingClientRect() | ||
); | ||
} | ||
} | ||
} | ||
prevChildren = children; | ||
children = slots.default ? runtimeCore.getTransitionRawChildren(slots.default()) : []; | ||
@@ -1089,2 +1016,12 @@ for (let i = 0; i < children.length; i++) { | ||
} | ||
if (prevChildren) { | ||
for (let i = 0; i < prevChildren.length; i++) { | ||
const child = prevChildren[i]; | ||
runtimeCore.setTransitionHooks( | ||
child, | ||
runtimeCore.resolveTransitionHooks(child, cssTransitionProps, state, instance) | ||
); | ||
positionMap.set(child, child.el.getBoundingClientRect()); | ||
} | ||
} | ||
return runtimeCore.createKNode(tag, null, children); | ||
@@ -1158,3 +1095,4 @@ }; | ||
addEventListener(el, lazy ? "change" : "input", (e) => { | ||
if (e.target.composing) return; | ||
if (e.target.composing) | ||
return; | ||
let domValue = el.value; | ||
@@ -1186,8 +1124,4 @@ if (trim) { | ||
el[assignKey] = getModelAssigner(knode); | ||
if (el.composing) return; | ||
const elValue = (number || el.type === "number") && !/^0\d/.test(el.value) ? shared.looseToNumber(el.value) : el.value; | ||
const newValue = value == null ? "" : value; | ||
if (elValue === newValue) { | ||
if (el.composing) | ||
return; | ||
} | ||
if (document.activeElement === el && el.type !== "range") { | ||
@@ -1197,7 +1131,13 @@ if (lazy) { | ||
} | ||
if (trim && el.value.trim() === newValue) { | ||
if (trim && el.value.trim() === value) { | ||
return; | ||
} | ||
if ((number || el.type === "number") && shared.looseToNumber(el.value) === value) { | ||
return; | ||
} | ||
} | ||
el.value = newValue; | ||
const newValue = value == null ? "" : value; | ||
if (el.value !== newValue) { | ||
el.value = newValue; | ||
} | ||
} | ||
@@ -1282,6 +1222,2 @@ }; | ||
); | ||
el._assigning = true; | ||
runtimeCore.nextTick(() => { | ||
el._assigning = false; | ||
}); | ||
}); | ||
@@ -1292,3 +1228,3 @@ el[assignKey] = getModelAssigner(knode); | ||
// <option>s. | ||
mounted(el, { value, modifiers: { number } }) { | ||
mounted(el, { value }) { | ||
setSelected(el, value); | ||
@@ -1299,12 +1235,9 @@ }, | ||
}, | ||
updated(el, { value, modifiers: { number } }) { | ||
if (!el._assigning) { | ||
setSelected(el, value); | ||
} | ||
updated(el, { value }) { | ||
setSelected(el, value); | ||
} | ||
}; | ||
function setSelected(el, value, number) { | ||
function setSelected(el, value) { | ||
const isMultiple = el.multiple; | ||
const isArrayValue = shared.isArray(value); | ||
if (isMultiple && !isArrayValue && !shared.isSet(value)) { | ||
if (isMultiple && !shared.isArray(value) && !shared.isSet(value)) { | ||
runtimeCore.warn( | ||
@@ -1319,15 +1252,13 @@ `<select multiple k-model> expects an Array or Set value for its binding, but got ${Object.prototype.toString.call(value).slice(8, -1)}.` | ||
if (isMultiple) { | ||
if (isArrayValue) { | ||
const optionType = typeof optionValue; | ||
if (optionType === "string" || optionType === "number") { | ||
option.selected = value.some((v) => String(v) === String(optionValue)); | ||
} else { | ||
option.selected = shared.looseIndexOf(value, optionValue) > -1; | ||
} | ||
if (shared.isArray(value)) { | ||
option.selected = shared.looseIndexOf(value, optionValue) > -1; | ||
} else { | ||
option.selected = value.has(optionValue); | ||
} | ||
} else if (shared.looseEqual(getValue(option), value)) { | ||
if (el.selectedIndex !== i) el.selectedIndex = i; | ||
return; | ||
} else { | ||
if (shared.looseEqual(getValue(option), value)) { | ||
if (el.selectedIndex !== i) | ||
el.selectedIndex = i; | ||
return; | ||
} | ||
} | ||
@@ -1435,11 +1366,10 @@ } | ||
const withModifiers = (fn, modifiers) => { | ||
const cache = fn._withMods || (fn._withMods = {}); | ||
const cacheKey = modifiers.join("."); | ||
return cache[cacheKey] || (cache[cacheKey] = (event, ...args) => { | ||
return (event, ...args) => { | ||
for (let i = 0; i < modifiers.length; i++) { | ||
const guard = modifierGuards[modifiers[i]]; | ||
if (guard && guard(event, modifiers)) return; | ||
if (guard && guard(event, modifiers)) | ||
return; | ||
} | ||
return fn(event, ...args); | ||
}); | ||
}; | ||
}; | ||
@@ -1456,5 +1386,3 @@ const keyNames = { | ||
const withKeys = (fn, modifiers) => { | ||
const cache = fn._withKeys || (fn._withKeys = {}); | ||
const cacheKey = modifiers.join("."); | ||
return cache[cacheKey] || (cache[cacheKey] = (event) => { | ||
return (event) => { | ||
if (!("key" in event)) { | ||
@@ -1467,3 +1395,3 @@ return; | ||
} | ||
}); | ||
}; | ||
}; | ||
@@ -1497,3 +1425,4 @@ | ||
const container = normalizeContainer(containerOrSelector); | ||
if (!container) return; | ||
if (!container) | ||
return; | ||
const component = app._component; | ||
@@ -1504,3 +1433,3 @@ if (!shared.isFunction(component) && !component.render && !component.template) { | ||
container.innerHTML = ""; | ||
const proxy = mount(container, false, resolveRootNamespace(container)); | ||
const proxy = mount(container, false, container instanceof SVGElement); | ||
if (container instanceof Element) { | ||
@@ -1524,3 +1453,3 @@ container.removeAttribute("k-cloak"); | ||
if (container) { | ||
return mount(container, true, resolveRootNamespace(container)); | ||
return mount(container, true, container instanceof SVGElement); | ||
} | ||
@@ -1530,13 +1459,5 @@ }; | ||
}; | ||
function resolveRootNamespace(container) { | ||
if (container instanceof SVGElement) { | ||
return "svg"; | ||
} | ||
if (typeof MathMLElement === "function" && container instanceof MathMLElement) { | ||
return "mathml"; | ||
} | ||
} | ||
function injectNativeTagCheck(app) { | ||
Object.defineProperty(app.config, "isNativeTag", { | ||
value: (tag) => shared.isHTMLTag(tag) || shared.isSVGTag(tag) || shared.isMathMLTag(tag), | ||
value: (tag) => shared.isHTMLTag(tag) || shared.isSVGTag(tag), | ||
writable: false | ||
@@ -1562,3 +1483,3 @@ }); | ||
- For kdu-cli: see https://kdujs-cli.web.app/guide/webpack.html#modifying-options-of-a-loader | ||
- For lahm: pass it via @lahmjs/plugin-kdu options.`; | ||
- For wite: pass it via @witejs/plugin-kdu options.`; | ||
Object.defineProperty(app.config, "compilerOptions", { | ||
@@ -1565,0 +1486,0 @@ get() { |
@@ -1,6 +0,1 @@ | ||
/** | ||
* @kdujs/runtime-dom-canary v3.20241118.0 | ||
* (c) 2021-present NKDuy | ||
* @license MIT | ||
**/ | ||
'use strict'; | ||
@@ -14,3 +9,2 @@ | ||
const svgNS = "http://www.w3.org/2000/svg"; | ||
const mathmlNS = "http://www.w3.org/1998/Math/MathML"; | ||
const doc = typeof document !== "undefined" ? document : null; | ||
@@ -28,4 +22,4 @@ const templateContainer = doc && /* @__PURE__ */ doc.createElement("template"); | ||
}, | ||
createElement: (tag, namespace, is, props) => { | ||
const el = namespace === "svg" ? doc.createElementNS(svgNS, tag) : namespace === "mathml" ? doc.createElementNS(mathmlNS, tag) : doc.createElement(tag, is ? { is } : void 0); | ||
createElement: (tag, isSVG, is, props) => { | ||
const el = isSVG ? doc.createElementNS(svgNS, tag) : doc.createElement(tag, is ? { is } : void 0); | ||
if (tag === "select" && props && props.multiple != null) { | ||
@@ -54,3 +48,3 @@ el.setAttribute("multiple", props.multiple); | ||
// As long as the user only uses trusted templates, this is safe. | ||
insertStaticContent(content, parent, anchor, namespace, start, end) { | ||
insertStaticContent(content, parent, anchor, isSVG, start, end) { | ||
const before = anchor ? anchor.previousSibling : parent.lastChild; | ||
@@ -60,8 +54,9 @@ if (start && (start === end || start.nextSibling)) { | ||
parent.insertBefore(start.cloneNode(true), anchor); | ||
if (start === end || !(start = start.nextSibling)) break; | ||
if (start === end || !(start = start.nextSibling)) | ||
break; | ||
} | ||
} else { | ||
templateContainer.innerHTML = namespace === "svg" ? `<svg>${content}</svg>` : namespace === "mathml" ? `<math>${content}</math>` : content; | ||
templateContainer.innerHTML = isSVG ? `<svg>${content}</svg>` : content; | ||
const template = templateContainer.content; | ||
if (namespace === "svg" || namespace === "mathml") { | ||
if (isSVG) { | ||
const wrapper = template.firstChild; | ||
@@ -202,4 +197,4 @@ while (wrapper.firstChild) { | ||
addTransitionClass(el, leaveFromClass); | ||
forceReflow(); | ||
addTransitionClass(el, leaveActiveClass); | ||
forceReflow(); | ||
nextFrame(() => { | ||
@@ -343,3 +338,4 @@ if (!el._isLeaving) { | ||
function toMs(s) { | ||
if (s === "auto") return 0; | ||
if (s === "auto") | ||
return 0; | ||
return Number(s.slice(0, -1).replace(",", ".")) * 1e3; | ||
@@ -365,7 +361,6 @@ } | ||
const kShowOriginalDisplay = Symbol("_kod"); | ||
const kShowHidden = Symbol("_ksh"); | ||
const kShowOldKey = Symbol("_kod"); | ||
const kShow = { | ||
beforeMount(el, { value }, { transition }) { | ||
el[kShowOriginalDisplay] = el.style.display === "none" ? "" : el.style.display; | ||
el[kShowOldKey] = el.style.display === "none" ? "" : el.style.display; | ||
if (transition && value) { | ||
@@ -383,3 +378,4 @@ transition.beforeEnter(el); | ||
updated(el, { value, oldValue }, { transition }) { | ||
if (!value === !oldValue) return; | ||
if (!value === !oldValue) | ||
return; | ||
if (transition) { | ||
@@ -404,4 +400,3 @@ if (value) { | ||
function setDisplay(el, value) { | ||
el.style.display = value ? el[kShowOriginalDisplay] : "none"; | ||
el[kShowHidden] = !value; | ||
el.style.display = value ? el[kShowOldKey] : "none"; | ||
} | ||
@@ -416,44 +411,21 @@ function initKShowForSSR() { | ||
const CSS_VAR_TEXT = Symbol(""); | ||
function useCssVars(getter) { | ||
return; | ||
} | ||
const displayRE = /(^|;)\s*display\s*:/; | ||
function patchStyle(el, prev, next) { | ||
const style = el.style; | ||
const isCssString = shared.isString(next); | ||
let hasControlledDisplay = false; | ||
if (next && !isCssString) { | ||
if (prev) { | ||
if (!shared.isString(prev)) { | ||
for (const key in prev) { | ||
if (next[key] == null) { | ||
setStyle(style, key, ""); | ||
} | ||
if (prev && !shared.isString(prev)) { | ||
for (const key in prev) { | ||
if (next[key] == null) { | ||
setStyle(style, key, ""); | ||
} | ||
} else { | ||
for (const prevStyle of prev.split(";")) { | ||
const key = prevStyle.slice(0, prevStyle.indexOf(":")).trim(); | ||
if (next[key] == null) { | ||
setStyle(style, key, ""); | ||
} | ||
} | ||
} | ||
} | ||
for (const key in next) { | ||
if (key === "display") { | ||
hasControlledDisplay = true; | ||
} | ||
setStyle(style, key, next[key]); | ||
} | ||
} else { | ||
const currentDisplay = style.display; | ||
if (isCssString) { | ||
if (prev !== next) { | ||
const cssVarText = style[CSS_VAR_TEXT]; | ||
if (cssVarText) { | ||
next += ";" + cssVarText; | ||
} | ||
style.cssText = next; | ||
hasControlledDisplay = displayRE.test(next); | ||
} | ||
@@ -463,7 +435,4 @@ } else if (prev) { | ||
} | ||
} | ||
if (kShowOriginalDisplay in el) { | ||
el[kShowOriginalDisplay] = hasControlledDisplay ? style.display : ""; | ||
if (el[kShowHidden]) { | ||
style.display = "none"; | ||
if (kShowOldKey in el) { | ||
style.display = currentDisplay; | ||
} | ||
@@ -477,3 +446,4 @@ } | ||
} else { | ||
if (val == null) val = ""; | ||
if (val == null) | ||
val = ""; | ||
if (name.startsWith("--")) { | ||
@@ -545,5 +515,6 @@ style.setProperty(name, val); | ||
!tag.includes("-")) { | ||
const oldValue = tag === "OPTION" ? el.getAttribute("value") || "" : el.value; | ||
el._value = value; | ||
const oldValue = tag === "OPTION" ? el.getAttribute("value") : el.value; | ||
const newValue = value == null ? "" : value; | ||
if (oldValue !== newValue || !("_value" in el)) { | ||
if (oldValue !== newValue) { | ||
el.value = newValue; | ||
@@ -554,3 +525,2 @@ } | ||
} | ||
el._value = value; | ||
return; | ||
@@ -593,6 +563,3 @@ } | ||
if (nextValue) { | ||
const invoker = invokers[rawName] = createInvoker( | ||
nextValue, | ||
instance | ||
); | ||
const invoker = invokers[rawName] = createInvoker(nextValue, instance); | ||
addEventListener(el, name, invoker, options); | ||
@@ -647,5 +614,3 @@ } else if (existingInvoker) { | ||
}; | ||
return value.map( | ||
(fn) => (e2) => !e2._stopped && fn && fn(e2) | ||
); | ||
return value.map((fn) => (e2) => !e2._stopped && fn && fn(e2)); | ||
} else { | ||
@@ -656,6 +621,4 @@ return value; | ||
const isNativeOn = (key) => key.charCodeAt(0) === 111 && key.charCodeAt(1) === 110 && // lowercase letter | ||
key.charCodeAt(2) > 96 && key.charCodeAt(2) < 123; | ||
const patchProp = (el, key, prevValue, nextValue, namespace, prevChildren, parentComponent, parentSuspense, unmountChildren) => { | ||
const isSVG = namespace === "svg"; | ||
const nativeOnRE = /^on[a-z]/; | ||
const patchProp = (el, key, prevValue, nextValue, isSVG = false, prevChildren, parentComponent, parentSuspense, unmountChildren) => { | ||
if (key === "class") { | ||
@@ -693,3 +656,3 @@ patchClass(el, nextValue, isSVG); | ||
} | ||
if (key in el && isNativeOn(key) && shared.isFunction(value)) { | ||
if (key in el && nativeOnRE.test(key) && shared.isFunction(value)) { | ||
return true; | ||
@@ -711,9 +674,3 @@ } | ||
} | ||
if (key === "width" || key === "height") { | ||
const tag = el.tagName; | ||
if (tag === "IMG" || tag === "VIDEO" || tag === "CANVAS" || tag === "SOURCE") { | ||
return false; | ||
} | ||
} | ||
if (isNativeOn(key) && shared.isString(value)) { | ||
if (nativeOnRE.test(key) && shared.isString(value)) { | ||
return false; | ||
@@ -776,8 +733,8 @@ } | ||
this._connected = false; | ||
if (this._ob) { | ||
this._ob.disconnect(); | ||
this._ob = null; | ||
} | ||
runtimeCore.nextTick(() => { | ||
if (!this._connected) { | ||
if (this._ob) { | ||
this._ob.disconnect(); | ||
this._ob = null; | ||
} | ||
render(null, this.shadowRoot); | ||
@@ -850,3 +807,3 @@ this._instance = null; | ||
_setAttr(key) { | ||
let value = this.hasAttribute(key) ? this.getAttribute(key) : void 0; | ||
let value = this.getAttribute(key); | ||
const camelKey = shared.camelize(key); | ||
@@ -947,2 +904,6 @@ if (this._numberProps && this._numberProps[camelKey]) { | ||
function useCssVars(getter) { | ||
return; | ||
} | ||
const positionMap = /* @__PURE__ */ new WeakMap(); | ||
@@ -1001,24 +962,3 @@ const newPositionMap = /* @__PURE__ */ new WeakMap(); | ||
let tag = rawProps.tag || runtimeCore.Fragment; | ||
prevChildren = []; | ||
if (children) { | ||
for (let i = 0; i < children.length; i++) { | ||
const child = children[i]; | ||
if (child.el && child.el instanceof Element) { | ||
prevChildren.push(child); | ||
runtimeCore.setTransitionHooks( | ||
child, | ||
runtimeCore.resolveTransitionHooks( | ||
child, | ||
cssTransitionProps, | ||
state, | ||
instance | ||
) | ||
); | ||
positionMap.set( | ||
child, | ||
child.el.getBoundingClientRect() | ||
); | ||
} | ||
} | ||
} | ||
prevChildren = children; | ||
children = slots.default ? runtimeCore.getTransitionRawChildren(slots.default()) : []; | ||
@@ -1034,2 +974,12 @@ for (let i = 0; i < children.length; i++) { | ||
} | ||
if (prevChildren) { | ||
for (let i = 0; i < prevChildren.length; i++) { | ||
const child = prevChildren[i]; | ||
runtimeCore.setTransitionHooks( | ||
child, | ||
runtimeCore.resolveTransitionHooks(child, cssTransitionProps, state, instance) | ||
); | ||
positionMap.set(child, child.el.getBoundingClientRect()); | ||
} | ||
} | ||
return runtimeCore.createKNode(tag, null, children); | ||
@@ -1103,3 +1053,4 @@ }; | ||
addEventListener(el, lazy ? "change" : "input", (e) => { | ||
if (e.target.composing) return; | ||
if (e.target.composing) | ||
return; | ||
let domValue = el.value; | ||
@@ -1131,8 +1082,4 @@ if (trim) { | ||
el[assignKey] = getModelAssigner(knode); | ||
if (el.composing) return; | ||
const elValue = (number || el.type === "number") && !/^0\d/.test(el.value) ? shared.looseToNumber(el.value) : el.value; | ||
const newValue = value == null ? "" : value; | ||
if (elValue === newValue) { | ||
if (el.composing) | ||
return; | ||
} | ||
if (document.activeElement === el && el.type !== "range") { | ||
@@ -1142,7 +1089,13 @@ if (lazy) { | ||
} | ||
if (trim && el.value.trim() === newValue) { | ||
if (trim && el.value.trim() === value) { | ||
return; | ||
} | ||
if ((number || el.type === "number") && shared.looseToNumber(el.value) === value) { | ||
return; | ||
} | ||
} | ||
el.value = newValue; | ||
const newValue = value == null ? "" : value; | ||
if (el.value !== newValue) { | ||
el.value = newValue; | ||
} | ||
} | ||
@@ -1227,6 +1180,2 @@ }; | ||
); | ||
el._assigning = true; | ||
runtimeCore.nextTick(() => { | ||
el._assigning = false; | ||
}); | ||
}); | ||
@@ -1237,3 +1186,3 @@ el[assignKey] = getModelAssigner(knode); | ||
// <option>s. | ||
mounted(el, { value, modifiers: { number } }) { | ||
mounted(el, { value }) { | ||
setSelected(el, value); | ||
@@ -1244,12 +1193,9 @@ }, | ||
}, | ||
updated(el, { value, modifiers: { number } }) { | ||
if (!el._assigning) { | ||
setSelected(el, value); | ||
} | ||
updated(el, { value }) { | ||
setSelected(el, value); | ||
} | ||
}; | ||
function setSelected(el, value, number) { | ||
function setSelected(el, value) { | ||
const isMultiple = el.multiple; | ||
const isArrayValue = shared.isArray(value); | ||
if (isMultiple && !isArrayValue && !shared.isSet(value)) { | ||
if (isMultiple && !shared.isArray(value) && !shared.isSet(value)) { | ||
return; | ||
@@ -1261,15 +1207,13 @@ } | ||
if (isMultiple) { | ||
if (isArrayValue) { | ||
const optionType = typeof optionValue; | ||
if (optionType === "string" || optionType === "number") { | ||
option.selected = value.some((v) => String(v) === String(optionValue)); | ||
} else { | ||
option.selected = shared.looseIndexOf(value, optionValue) > -1; | ||
} | ||
if (shared.isArray(value)) { | ||
option.selected = shared.looseIndexOf(value, optionValue) > -1; | ||
} else { | ||
option.selected = value.has(optionValue); | ||
} | ||
} else if (shared.looseEqual(getValue(option), value)) { | ||
if (el.selectedIndex !== i) el.selectedIndex = i; | ||
return; | ||
} else { | ||
if (shared.looseEqual(getValue(option), value)) { | ||
if (el.selectedIndex !== i) | ||
el.selectedIndex = i; | ||
return; | ||
} | ||
} | ||
@@ -1377,11 +1321,10 @@ } | ||
const withModifiers = (fn, modifiers) => { | ||
const cache = fn._withMods || (fn._withMods = {}); | ||
const cacheKey = modifiers.join("."); | ||
return cache[cacheKey] || (cache[cacheKey] = (event, ...args) => { | ||
return (event, ...args) => { | ||
for (let i = 0; i < modifiers.length; i++) { | ||
const guard = modifierGuards[modifiers[i]]; | ||
if (guard && guard(event, modifiers)) return; | ||
if (guard && guard(event, modifiers)) | ||
return; | ||
} | ||
return fn(event, ...args); | ||
}); | ||
}; | ||
}; | ||
@@ -1398,5 +1341,3 @@ const keyNames = { | ||
const withKeys = (fn, modifiers) => { | ||
const cache = fn._withKeys || (fn._withKeys = {}); | ||
const cacheKey = modifiers.join("."); | ||
return cache[cacheKey] || (cache[cacheKey] = (event) => { | ||
return (event) => { | ||
if (!("key" in event)) { | ||
@@ -1409,3 +1350,3 @@ return; | ||
} | ||
}); | ||
}; | ||
}; | ||
@@ -1435,3 +1376,4 @@ | ||
const container = normalizeContainer(containerOrSelector); | ||
if (!container) return; | ||
if (!container) | ||
return; | ||
const component = app._component; | ||
@@ -1442,3 +1384,3 @@ if (!shared.isFunction(component) && !component.render && !component.template) { | ||
container.innerHTML = ""; | ||
const proxy = mount(container, false, resolveRootNamespace(container)); | ||
const proxy = mount(container, false, container instanceof SVGElement); | ||
if (container instanceof Element) { | ||
@@ -1458,3 +1400,3 @@ container.removeAttribute("k-cloak"); | ||
if (container) { | ||
return mount(container, true, resolveRootNamespace(container)); | ||
return mount(container, true, container instanceof SVGElement); | ||
} | ||
@@ -1464,10 +1406,2 @@ }; | ||
}; | ||
function resolveRootNamespace(container) { | ||
if (container instanceof SVGElement) { | ||
return "svg"; | ||
} | ||
if (typeof MathMLElement === "function" && container instanceof MathMLElement) { | ||
return "mathml"; | ||
} | ||
} | ||
function normalizeContainer(container) { | ||
@@ -1474,0 +1408,0 @@ if (shared.isString(container)) { |
@@ -1,2 +0,2 @@ | ||
import { SetupContext, RenderFunction, ComputedOptions, MethodOptions, ComponentOptionsMixin, EmitsOptions, ComponentInjectOptions, SlotsType, ComponentOptionsWithoutProps, ComponentOptionsWithArrayProps, ComponentPropsOptions, ComponentOptionsWithObjectProps, ExtractPropTypes, DefineComponent, RootHydrateFunction, ConcreteComponent, BaseTransitionProps, FunctionalComponent, ObjectDirective, KNodeRef, RootRenderFunction, CreateAppFunction } from '@kdujs/runtime-core'; | ||
import { SetupContext, RenderFunction, ComputedOptions, MethodOptions, ComponentOptionsMixin, EmitsOptions, ComponentInjectOptions, SlotsType, ComponentOptionsWithoutProps, ComponentOptionsWithArrayProps, ComponentPropsOptions, ComponentOptionsWithObjectProps, ExtractPropTypes, ComponentPublicInstance, RootHydrateFunction, ConcreteComponent, BaseTransitionProps, FunctionalComponent, ObjectDirective, KNodeRef, RootRenderFunction, CreateAppFunction } from '@kdujs/runtime-core'; | ||
export * from '@kdujs/runtime-core'; | ||
@@ -20,3 +20,5 @@ import * as CSS from 'csstype'; | ||
}): KduElementConstructor<ExtractPropTypes<PropsOptions>>; | ||
export declare function defineCustomElement<P>(options: DefineComponent<P, any, any, any>): KduElementConstructor<ExtractPropTypes<P>>; | ||
export declare function defineCustomElement(options: { | ||
new (...args: any[]): ComponentPublicInstance; | ||
}): KduElementConstructor; | ||
/*! #__NO_SIDE_EFFECTS__ */ | ||
@@ -96,3 +98,2 @@ export declare const defineSSRCustomElement: typeof defineCustomElement; | ||
[assignKey]: AssignerFn; | ||
_assigning?: boolean; | ||
}>; | ||
@@ -105,29 +106,16 @@ export declare const kModelText: ModelDirective<HTMLInputElement | HTMLTextAreaElement>; | ||
type ModifierGuardsKeys = 'stop' | 'prevent' | 'self' | 'ctrl' | 'shift' | 'alt' | 'meta' | 'left' | 'middle' | 'right' | 'exact'; | ||
/** | ||
* @private | ||
*/ | ||
export declare const withModifiers: <T extends (event: Event, ...args: unknown[]) => any>(fn: T & { | ||
_withMods?: { | ||
[key: string]: T; | ||
}; | ||
}, modifiers: ModifierGuardsKeys[]) => T; | ||
export declare const withModifiers: (fn: Function, modifiers: string[]) => (event: Event, ...args: unknown[]) => any; | ||
/** | ||
* @private | ||
*/ | ||
export declare const withKeys: <T extends (event: KeyboardEvent) => any>(fn: T & { | ||
_withKeys?: { | ||
[k: string]: T; | ||
}; | ||
}, modifiers: string[]) => T; | ||
export declare const withKeys: (fn: Function, modifiers: string[]) => (event: KeyboardEvent) => any; | ||
declare const kShowOriginalDisplay: unique symbol; | ||
declare const kShowHidden: unique symbol; | ||
declare const kShowOldKey: unique symbol; | ||
interface KShowElement extends HTMLElement { | ||
[kShowOriginalDisplay]: string; | ||
[kShowHidden]: boolean; | ||
[kShowOldKey]: string; | ||
} | ||
export declare const kShow: ObjectDirective<KShowElement> & { | ||
name?: 'show'; | ||
}; | ||
export declare const kShow: ObjectDirective<KShowElement>; | ||
@@ -147,3 +135,3 @@ export interface CSSProperties extends CSS.Properties<string | number>, CSS.PropertiesHyphen<string | number> { | ||
type Numberish = number | string; | ||
export interface AriaAttributes { | ||
interface AriaAttributes { | ||
/** Identifies the currently active element when DOM focus is on a composite widget, textbox, group, or application. */ | ||
@@ -290,3 +278,3 @@ 'aria-activedescendant'?: string; | ||
*/ | ||
'aria-relevant'?: 'additions' | 'additions removals' | 'additions text' | 'all' | 'removals' | 'removals additions' | 'removals text' | 'text' | 'text additions' | 'text removals'; | ||
'aria-relevant'?: 'additions' | 'additions text' | 'all' | 'removals' | 'text'; | ||
/** Indicates that user input is required on the element before a form may be submitted. */ | ||
@@ -335,3 +323,3 @@ 'aria-required'?: Booleanish; | ||
} | ||
export type StyleValue = false | null | undefined | string | CSSProperties | Array<StyleValue>; | ||
export type StyleValue = string | CSSProperties | Array<StyleValue>; | ||
export interface HTMLAttributes extends AriaAttributes, EventHandlers<Events> { | ||
@@ -342,3 +330,3 @@ innerHTML?: string; | ||
accesskey?: string; | ||
contenteditable?: Booleanish | 'inherit' | 'plaintext-only'; | ||
contenteditable?: Booleanish | 'inherit'; | ||
contextmenu?: string; | ||
@@ -433,3 +421,3 @@ dir?: string; | ||
type?: 'submit' | 'reset' | 'button'; | ||
value?: string | ReadonlyArray<string> | number; | ||
value?: string | string[] | number; | ||
} | ||
@@ -448,7 +436,6 @@ export interface CanvasHTMLAttributes extends HTMLAttributes { | ||
export interface DataHTMLAttributes extends HTMLAttributes { | ||
value?: string | ReadonlyArray<string> | number; | ||
value?: string | string[] | number; | ||
} | ||
export interface DetailsHTMLAttributes extends HTMLAttributes { | ||
open?: Booleanish; | ||
onToggle?: (payload: ToggleEvent) => void; | ||
} | ||
@@ -490,8 +477,5 @@ export interface DelHTMLAttributes extends HTMLAttributes { | ||
allowtransparency?: Booleanish; | ||
/** @deprecated */ | ||
frameborder?: Numberish; | ||
height?: Numberish; | ||
/** @deprecated */ | ||
marginheight?: Numberish; | ||
/** @deprecated */ | ||
marginwidth?: Numberish; | ||
@@ -501,3 +485,2 @@ name?: string; | ||
sandbox?: string; | ||
/** @deprecated */ | ||
scrolling?: string; | ||
@@ -514,3 +497,2 @@ seamless?: Booleanish; | ||
height?: Numberish; | ||
loading?: 'eager' | 'lazy'; | ||
referrerpolicy?: HTMLAttributeReferrerPolicy; | ||
@@ -522,2 +504,3 @@ sizes?: string; | ||
width?: Numberish; | ||
loading?: 'lazy' | 'eager'; | ||
} | ||
@@ -538,3 +521,2 @@ export interface InsHTMLAttributes extends HTMLAttributes { | ||
disabled?: Booleanish; | ||
enterKeyHint?: 'enter' | 'done' | 'go' | 'next' | 'previous' | 'search' | 'send'; | ||
form?: string; | ||
@@ -580,3 +562,3 @@ formaction?: string; | ||
export interface LiHTMLAttributes extends HTMLAttributes { | ||
value?: string | ReadonlyArray<string> | number; | ||
value?: string | string[] | number; | ||
} | ||
@@ -594,3 +576,2 @@ export interface LinkHTMLAttributes extends HTMLAttributes { | ||
type?: string; | ||
charset?: string; | ||
} | ||
@@ -628,3 +609,3 @@ export interface MapHTMLAttributes extends HTMLAttributes { | ||
optimum?: Numberish; | ||
value?: string | ReadonlyArray<string> | number; | ||
value?: string | string[] | number; | ||
} | ||
@@ -667,11 +648,10 @@ export interface QuoteHTMLAttributes extends HTMLAttributes { | ||
name?: string; | ||
value?: string | ReadonlyArray<string> | number; | ||
value?: string | string[] | number; | ||
} | ||
export interface ProgressHTMLAttributes extends HTMLAttributes { | ||
max?: Numberish; | ||
value?: string | ReadonlyArray<string> | number; | ||
value?: string | string[] | number; | ||
} | ||
export interface ScriptHTMLAttributes extends HTMLAttributes { | ||
async?: Booleanish; | ||
/** @deprecated */ | ||
charset?: string; | ||
@@ -715,3 +695,2 @@ crossorigin?: string; | ||
summary?: string; | ||
width?: Numberish; | ||
} | ||
@@ -732,3 +711,3 @@ export interface TextareaHTMLAttributes extends HTMLAttributes { | ||
rows?: Numberish; | ||
value?: string | ReadonlyArray<string> | number | null; | ||
value?: string | string[] | number; | ||
wrap?: string; | ||
@@ -742,5 +721,2 @@ } | ||
scope?: string; | ||
abbr?: string; | ||
height?: Numberish; | ||
width?: Numberish; | ||
valign?: 'top' | 'middle' | 'bottom' | 'baseline'; | ||
@@ -754,3 +730,2 @@ } | ||
scope?: string; | ||
abbr?: string; | ||
} | ||
@@ -773,3 +748,2 @@ export interface TimeHTMLAttributes extends HTMLAttributes { | ||
disablePictureInPicture?: Booleanish; | ||
disableRemotePlayback?: Booleanish; | ||
} | ||
@@ -817,3 +791,2 @@ export interface WebViewHTMLAttributes extends HTMLAttributes { | ||
tabindex?: Numberish; | ||
crossOrigin?: 'anonymous' | 'use-credentials' | ''; | ||
'accent-height'?: Numberish; | ||
@@ -1049,3 +1022,2 @@ accumulate?: 'none' | 'sum'; | ||
xmlns?: string; | ||
xmlnsXlink?: string; | ||
y1?: Numberish; | ||
@@ -1296,4 +1268,3 @@ y2?: Numberish; | ||
onSelect: Event; | ||
onScroll: Event; | ||
onScrollend: Event; | ||
onScroll: UIEvent; | ||
onTouchcancel: TouchEvent; | ||
@@ -1300,0 +1271,0 @@ onTouchend: TouchEvent; |
@@ -1,12 +0,6 @@ | ||
/** | ||
* @kdujs/runtime-dom-canary v3.20241118.0 | ||
* (c) 2021-present NKDuy | ||
* @license MIT | ||
**/ | ||
import { h, BaseTransition, BaseTransitionPropsValidators, assertNumber, getCurrentInstance, warn, onMounted, watchPostEffect, onUnmounted, Fragment, Static, camelize, callWithAsyncErrorHandling, defineComponent, nextTick, createKNode, useTransitionState, onUpdated, toRaw, getTransitionRawChildren, setTransitionHooks, resolveTransitionHooks, isRuntimeOnly, createRenderer, createHydrationRenderer } from '@kdujs/runtime-core'; | ||
import { h, BaseTransition, BaseTransitionPropsValidators, assertNumber, warn, camelize, callWithAsyncErrorHandling, defineComponent, nextTick, createKNode, getCurrentInstance, watchPostEffect, onMounted, onUnmounted, Fragment, Static, useTransitionState, onUpdated, toRaw, getTransitionRawChildren, setTransitionHooks, resolveTransitionHooks, isRuntimeOnly, createRenderer, createHydrationRenderer } from '@kdujs/runtime-core'; | ||
export * from '@kdujs/runtime-core'; | ||
import { extend, isObject, toNumber, isArray, isString, hyphenate, capitalize, isSpecialBooleanAttr, includeBooleanAttr, isFunction, NOOP, isOn, isModelListener, camelize as camelize$1, EMPTY_OBJ, looseToNumber, looseIndexOf, isSet, looseEqual, invokeArrayFns, isHTMLTag, isSVGTag, isMathMLTag } from '@kdujs/shared'; | ||
import { extend, isObject, toNumber, isArray, isString, hyphenate, capitalize, isSpecialBooleanAttr, includeBooleanAttr, isOn, isModelListener, isFunction, camelize as camelize$1, EMPTY_OBJ, looseToNumber, looseIndexOf, isSet, looseEqual, invokeArrayFns, isHTMLTag, isSVGTag } from '@kdujs/shared'; | ||
const svgNS = "http://www.w3.org/2000/svg"; | ||
const mathmlNS = "http://www.w3.org/1998/Math/MathML"; | ||
const doc = typeof document !== "undefined" ? document : null; | ||
@@ -24,4 +18,4 @@ const templateContainer = doc && /* @__PURE__ */ doc.createElement("template"); | ||
}, | ||
createElement: (tag, namespace, is, props) => { | ||
const el = namespace === "svg" ? doc.createElementNS(svgNS, tag) : namespace === "mathml" ? doc.createElementNS(mathmlNS, tag) : doc.createElement(tag, is ? { is } : void 0); | ||
createElement: (tag, isSVG, is, props) => { | ||
const el = isSVG ? doc.createElementNS(svgNS, tag) : doc.createElement(tag, is ? { is } : void 0); | ||
if (tag === "select" && props && props.multiple != null) { | ||
@@ -50,3 +44,3 @@ el.setAttribute("multiple", props.multiple); | ||
// As long as the user only uses trusted templates, this is safe. | ||
insertStaticContent(content, parent, anchor, namespace, start, end) { | ||
insertStaticContent(content, parent, anchor, isSVG, start, end) { | ||
const before = anchor ? anchor.previousSibling : parent.lastChild; | ||
@@ -56,8 +50,9 @@ if (start && (start === end || start.nextSibling)) { | ||
parent.insertBefore(start.cloneNode(true), anchor); | ||
if (start === end || !(start = start.nextSibling)) break; | ||
if (start === end || !(start = start.nextSibling)) | ||
break; | ||
} | ||
} else { | ||
templateContainer.innerHTML = namespace === "svg" ? `<svg>${content}</svg>` : namespace === "mathml" ? `<math>${content}</math>` : content; | ||
templateContainer.innerHTML = isSVG ? `<svg>${content}</svg>` : content; | ||
const template = templateContainer.content; | ||
if (namespace === "svg" || namespace === "mathml") { | ||
if (isSVG) { | ||
const wrapper = template.firstChild; | ||
@@ -198,4 +193,4 @@ while (wrapper.firstChild) { | ||
addTransitionClass(el, leaveFromClass); | ||
forceReflow(); | ||
addTransitionClass(el, leaveActiveClass); | ||
forceReflow(); | ||
nextFrame(() => { | ||
@@ -342,3 +337,4 @@ if (!el._isLeaving) { | ||
function toMs(s) { | ||
if (s === "auto") return 0; | ||
if (s === "auto") | ||
return 0; | ||
return Number(s.slice(0, -1).replace(",", ".")) * 1e3; | ||
@@ -364,7 +360,6 @@ } | ||
const kShowOriginalDisplay = Symbol("_kod"); | ||
const kShowHidden = Symbol("_ksh"); | ||
const kShowOldKey = Symbol("_kod"); | ||
const kShow = { | ||
beforeMount(el, { value }, { transition }) { | ||
el[kShowOriginalDisplay] = el.style.display === "none" ? "" : el.style.display; | ||
el[kShowOldKey] = el.style.display === "none" ? "" : el.style.display; | ||
if (transition && value) { | ||
@@ -382,3 +377,4 @@ transition.beforeEnter(el); | ||
updated(el, { value, oldValue }, { transition }) { | ||
if (!value === !oldValue) return; | ||
if (!value === !oldValue) | ||
return; | ||
if (transition) { | ||
@@ -402,8 +398,4 @@ if (value) { | ||
}; | ||
if (!!(process.env.NODE_ENV !== "production")) { | ||
kShow.name = "show"; | ||
} | ||
function setDisplay(el, value) { | ||
el.style.display = value ? el[kShowOriginalDisplay] : "none"; | ||
el[kShowHidden] = !value; | ||
el.style.display = value ? el[kShowOldKey] : "none"; | ||
} | ||
@@ -418,104 +410,21 @@ function initKShowForSSR() { | ||
const CSS_VAR_TEXT = Symbol(!!(process.env.NODE_ENV !== "production") ? "CSS_VAR_TEXT" : ""); | ||
function useCssVars(getter) { | ||
const instance = getCurrentInstance(); | ||
if (!instance) { | ||
!!(process.env.NODE_ENV !== "production") && warn(`useCssVars is called without current active component instance.`); | ||
return; | ||
} | ||
const updateTeleports = instance.ut = (vars = getter(instance.proxy)) => { | ||
Array.from( | ||
document.querySelectorAll(`[data-k-owner="${instance.uid}"]`) | ||
).forEach((node) => setVarsOnNode(node, vars)); | ||
}; | ||
if (!!(process.env.NODE_ENV !== "production")) { | ||
instance.getCssVars = () => getter(instance.proxy); | ||
} | ||
const setVars = () => { | ||
const vars = getter(instance.proxy); | ||
setVarsOnKNode(instance.subTree, vars); | ||
updateTeleports(vars); | ||
}; | ||
onMounted(() => { | ||
watchPostEffect(setVars); | ||
const ob = new MutationObserver(setVars); | ||
ob.observe(instance.subTree.el.parentNode, { childList: true }); | ||
onUnmounted(() => ob.disconnect()); | ||
}); | ||
} | ||
function setVarsOnKNode(knode, vars) { | ||
if (knode.shapeFlag & 128) { | ||
const suspense = knode.suspense; | ||
knode = suspense.activeBranch; | ||
if (suspense.pendingBranch && !suspense.isHydrating) { | ||
suspense.effects.push(() => { | ||
setVarsOnKNode(suspense.activeBranch, vars); | ||
}); | ||
} | ||
} | ||
while (knode.component) { | ||
knode = knode.component.subTree; | ||
} | ||
if (knode.shapeFlag & 1 && knode.el) { | ||
setVarsOnNode(knode.el, vars); | ||
} else if (knode.type === Fragment) { | ||
knode.children.forEach((c) => setVarsOnKNode(c, vars)); | ||
} else if (knode.type === Static) { | ||
let { el, anchor } = knode; | ||
while (el) { | ||
setVarsOnNode(el, vars); | ||
if (el === anchor) break; | ||
el = el.nextSibling; | ||
} | ||
} | ||
} | ||
function setVarsOnNode(el, vars) { | ||
if (el.nodeType === 1) { | ||
const style = el.style; | ||
let cssText = ""; | ||
for (const key in vars) { | ||
style.setProperty(`--${key}`, vars[key]); | ||
cssText += `--${key}: ${vars[key]};`; | ||
} | ||
style[CSS_VAR_TEXT] = cssText; | ||
} | ||
} | ||
const displayRE = /(^|;)\s*display\s*:/; | ||
function patchStyle(el, prev, next) { | ||
const style = el.style; | ||
const isCssString = isString(next); | ||
let hasControlledDisplay = false; | ||
if (next && !isCssString) { | ||
if (prev) { | ||
if (!isString(prev)) { | ||
for (const key in prev) { | ||
if (next[key] == null) { | ||
setStyle(style, key, ""); | ||
} | ||
if (prev && !isString(prev)) { | ||
for (const key in prev) { | ||
if (next[key] == null) { | ||
setStyle(style, key, ""); | ||
} | ||
} else { | ||
for (const prevStyle of prev.split(";")) { | ||
const key = prevStyle.slice(0, prevStyle.indexOf(":")).trim(); | ||
if (next[key] == null) { | ||
setStyle(style, key, ""); | ||
} | ||
} | ||
} | ||
} | ||
for (const key in next) { | ||
if (key === "display") { | ||
hasControlledDisplay = true; | ||
} | ||
setStyle(style, key, next[key]); | ||
} | ||
} else { | ||
const currentDisplay = style.display; | ||
if (isCssString) { | ||
if (prev !== next) { | ||
const cssVarText = style[CSS_VAR_TEXT]; | ||
if (cssVarText) { | ||
next += ";" + cssVarText; | ||
} | ||
style.cssText = next; | ||
hasControlledDisplay = displayRE.test(next); | ||
} | ||
@@ -525,7 +434,4 @@ } else if (prev) { | ||
} | ||
} | ||
if (kShowOriginalDisplay in el) { | ||
el[kShowOriginalDisplay] = hasControlledDisplay ? style.display : ""; | ||
if (el[kShowHidden]) { | ||
style.display = "none"; | ||
if (kShowOldKey in el) { | ||
style.display = currentDisplay; | ||
} | ||
@@ -540,3 +446,4 @@ } | ||
} else { | ||
if (val == null) val = ""; | ||
if (val == null) | ||
val = ""; | ||
if (!!(process.env.NODE_ENV !== "production")) { | ||
@@ -615,5 +522,6 @@ if (semicolonRE.test(val)) { | ||
!tag.includes("-")) { | ||
const oldValue = tag === "OPTION" ? el.getAttribute("value") || "" : el.value; | ||
el._value = value; | ||
const oldValue = tag === "OPTION" ? el.getAttribute("value") : el.value; | ||
const newValue = value == null ? "" : value; | ||
if (oldValue !== newValue || !("_value" in el)) { | ||
if (oldValue !== newValue) { | ||
el.value = newValue; | ||
@@ -624,3 +532,2 @@ } | ||
} | ||
el._value = value; | ||
return; | ||
@@ -665,10 +572,7 @@ } | ||
if (nextValue && existingInvoker) { | ||
existingInvoker.value = !!(process.env.NODE_ENV !== "production") ? sanitizeEventValue(nextValue, rawName) : nextValue; | ||
existingInvoker.value = nextValue; | ||
} else { | ||
const [name, options] = parseName(rawName); | ||
if (nextValue) { | ||
const invoker = invokers[rawName] = createInvoker( | ||
!!(process.env.NODE_ENV !== "production") ? sanitizeEventValue(nextValue, rawName) : nextValue, | ||
instance | ||
); | ||
const invoker = invokers[rawName] = createInvoker(nextValue, instance); | ||
addEventListener(el, name, invoker, options); | ||
@@ -716,12 +620,2 @@ } else if (existingInvoker) { | ||
} | ||
function sanitizeEventValue(value, propName) { | ||
if (isFunction(value) || isArray(value)) { | ||
return value; | ||
} | ||
warn( | ||
`Wrong type passed as event handler to ${propName} - did you forget @ or : in front of your prop? | ||
Expected function or array of functions, received type ${typeof value}.` | ||
); | ||
return NOOP; | ||
} | ||
function patchStopImmediatePropagation(e, value) { | ||
@@ -734,5 +628,3 @@ if (isArray(value)) { | ||
}; | ||
return value.map( | ||
(fn) => (e2) => !e2._stopped && fn && fn(e2) | ||
); | ||
return value.map((fn) => (e2) => !e2._stopped && fn && fn(e2)); | ||
} else { | ||
@@ -743,6 +635,4 @@ return value; | ||
const isNativeOn = (key) => key.charCodeAt(0) === 111 && key.charCodeAt(1) === 110 && // lowercase letter | ||
key.charCodeAt(2) > 96 && key.charCodeAt(2) < 123; | ||
const patchProp = (el, key, prevValue, nextValue, namespace, prevChildren, parentComponent, parentSuspense, unmountChildren) => { | ||
const isSVG = namespace === "svg"; | ||
const nativeOnRE = /^on[a-z]/; | ||
const patchProp = (el, key, prevValue, nextValue, isSVG = false, prevChildren, parentComponent, parentSuspense, unmountChildren) => { | ||
if (key === "class") { | ||
@@ -780,3 +670,3 @@ patchClass(el, nextValue, isSVG); | ||
} | ||
if (key in el && isNativeOn(key) && isFunction(value)) { | ||
if (key in el && nativeOnRE.test(key) && isFunction(value)) { | ||
return true; | ||
@@ -798,9 +688,3 @@ } | ||
} | ||
if (key === "width" || key === "height") { | ||
const tag = el.tagName; | ||
if (tag === "IMG" || tag === "VIDEO" || tag === "CANVAS" || tag === "SOURCE") { | ||
return false; | ||
} | ||
} | ||
if (isNativeOn(key) && isString(value)) { | ||
if (nativeOnRE.test(key) && isString(value)) { | ||
return false; | ||
@@ -868,8 +752,8 @@ } | ||
this._connected = false; | ||
if (this._ob) { | ||
this._ob.disconnect(); | ||
this._ob = null; | ||
} | ||
nextTick(() => { | ||
if (!this._connected) { | ||
if (this._ob) { | ||
this._ob.disconnect(); | ||
this._ob = null; | ||
} | ||
render(null, this.shadowRoot); | ||
@@ -942,3 +826,3 @@ this._instance = null; | ||
_setAttr(key) { | ||
let value = this.hasAttribute(key) ? this.getAttribute(key) : void 0; | ||
let value = this.getAttribute(key); | ||
const camelKey = camelize$1(key); | ||
@@ -1056,2 +940,61 @@ if (this._numberProps && this._numberProps[camelKey]) { | ||
function useCssVars(getter) { | ||
const instance = getCurrentInstance(); | ||
if (!instance) { | ||
!!(process.env.NODE_ENV !== "production") && warn(`useCssVars is called without current active component instance.`); | ||
return; | ||
} | ||
const updateTeleports = instance.ut = (vars = getter(instance.proxy)) => { | ||
Array.from( | ||
document.querySelectorAll(`[data-k-owner="${instance.uid}"]`) | ||
).forEach((node) => setVarsOnNode(node, vars)); | ||
}; | ||
const setVars = () => { | ||
const vars = getter(instance.proxy); | ||
setVarsOnKNode(instance.subTree, vars); | ||
updateTeleports(vars); | ||
}; | ||
watchPostEffect(setVars); | ||
onMounted(() => { | ||
const ob = new MutationObserver(setVars); | ||
ob.observe(instance.subTree.el.parentNode, { childList: true }); | ||
onUnmounted(() => ob.disconnect()); | ||
}); | ||
} | ||
function setVarsOnKNode(knode, vars) { | ||
if (knode.shapeFlag & 128) { | ||
const suspense = knode.suspense; | ||
knode = suspense.activeBranch; | ||
if (suspense.pendingBranch && !suspense.isHydrating) { | ||
suspense.effects.push(() => { | ||
setVarsOnKNode(suspense.activeBranch, vars); | ||
}); | ||
} | ||
} | ||
while (knode.component) { | ||
knode = knode.component.subTree; | ||
} | ||
if (knode.shapeFlag & 1 && knode.el) { | ||
setVarsOnNode(knode.el, vars); | ||
} else if (knode.type === Fragment) { | ||
knode.children.forEach((c) => setVarsOnKNode(c, vars)); | ||
} else if (knode.type === Static) { | ||
let { el, anchor } = knode; | ||
while (el) { | ||
setVarsOnNode(el, vars); | ||
if (el === anchor) | ||
break; | ||
el = el.nextSibling; | ||
} | ||
} | ||
} | ||
function setVarsOnNode(el, vars) { | ||
if (el.nodeType === 1) { | ||
const style = el.style; | ||
for (const key in vars) { | ||
style.setProperty(`--${key}`, vars[key]); | ||
} | ||
} | ||
} | ||
const positionMap = /* @__PURE__ */ new WeakMap(); | ||
@@ -1110,24 +1053,3 @@ const newPositionMap = /* @__PURE__ */ new WeakMap(); | ||
let tag = rawProps.tag || Fragment; | ||
prevChildren = []; | ||
if (children) { | ||
for (let i = 0; i < children.length; i++) { | ||
const child = children[i]; | ||
if (child.el && child.el instanceof Element) { | ||
prevChildren.push(child); | ||
setTransitionHooks( | ||
child, | ||
resolveTransitionHooks( | ||
child, | ||
cssTransitionProps, | ||
state, | ||
instance | ||
) | ||
); | ||
positionMap.set( | ||
child, | ||
child.el.getBoundingClientRect() | ||
); | ||
} | ||
} | ||
} | ||
prevChildren = children; | ||
children = slots.default ? getTransitionRawChildren(slots.default()) : []; | ||
@@ -1145,2 +1067,12 @@ for (let i = 0; i < children.length; i++) { | ||
} | ||
if (prevChildren) { | ||
for (let i = 0; i < prevChildren.length; i++) { | ||
const child = prevChildren[i]; | ||
setTransitionHooks( | ||
child, | ||
resolveTransitionHooks(child, cssTransitionProps, state, instance) | ||
); | ||
positionMap.set(child, child.el.getBoundingClientRect()); | ||
} | ||
} | ||
return createKNode(tag, null, children); | ||
@@ -1214,3 +1146,4 @@ }; | ||
addEventListener(el, lazy ? "change" : "input", (e) => { | ||
if (e.target.composing) return; | ||
if (e.target.composing) | ||
return; | ||
let domValue = el.value; | ||
@@ -1242,8 +1175,4 @@ if (trim) { | ||
el[assignKey] = getModelAssigner(knode); | ||
if (el.composing) return; | ||
const elValue = (number || el.type === "number") && !/^0\d/.test(el.value) ? looseToNumber(el.value) : el.value; | ||
const newValue = value == null ? "" : value; | ||
if (elValue === newValue) { | ||
if (el.composing) | ||
return; | ||
} | ||
if (document.activeElement === el && el.type !== "range") { | ||
@@ -1253,7 +1182,13 @@ if (lazy) { | ||
} | ||
if (trim && el.value.trim() === newValue) { | ||
if (trim && el.value.trim() === value) { | ||
return; | ||
} | ||
if ((number || el.type === "number") && looseToNumber(el.value) === value) { | ||
return; | ||
} | ||
} | ||
el.value = newValue; | ||
const newValue = value == null ? "" : value; | ||
if (el.value !== newValue) { | ||
el.value = newValue; | ||
} | ||
} | ||
@@ -1338,6 +1273,2 @@ }; | ||
); | ||
el._assigning = true; | ||
nextTick(() => { | ||
el._assigning = false; | ||
}); | ||
}); | ||
@@ -1348,3 +1279,3 @@ el[assignKey] = getModelAssigner(knode); | ||
// <option>s. | ||
mounted(el, { value, modifiers: { number } }) { | ||
mounted(el, { value }) { | ||
setSelected(el, value); | ||
@@ -1355,12 +1286,9 @@ }, | ||
}, | ||
updated(el, { value, modifiers: { number } }) { | ||
if (!el._assigning) { | ||
setSelected(el, value); | ||
} | ||
updated(el, { value }) { | ||
setSelected(el, value); | ||
} | ||
}; | ||
function setSelected(el, value, number) { | ||
function setSelected(el, value) { | ||
const isMultiple = el.multiple; | ||
const isArrayValue = isArray(value); | ||
if (isMultiple && !isArrayValue && !isSet(value)) { | ||
if (isMultiple && !isArray(value) && !isSet(value)) { | ||
!!(process.env.NODE_ENV !== "production") && warn( | ||
@@ -1375,15 +1303,13 @@ `<select multiple k-model> expects an Array or Set value for its binding, but got ${Object.prototype.toString.call(value).slice(8, -1)}.` | ||
if (isMultiple) { | ||
if (isArrayValue) { | ||
const optionType = typeof optionValue; | ||
if (optionType === "string" || optionType === "number") { | ||
option.selected = value.some((v) => String(v) === String(optionValue)); | ||
} else { | ||
option.selected = looseIndexOf(value, optionValue) > -1; | ||
} | ||
if (isArray(value)) { | ||
option.selected = looseIndexOf(value, optionValue) > -1; | ||
} else { | ||
option.selected = value.has(optionValue); | ||
} | ||
} else if (looseEqual(getValue(option), value)) { | ||
if (el.selectedIndex !== i) el.selectedIndex = i; | ||
return; | ||
} else { | ||
if (looseEqual(getValue(option), value)) { | ||
if (el.selectedIndex !== i) | ||
el.selectedIndex = i; | ||
return; | ||
} | ||
} | ||
@@ -1491,11 +1417,10 @@ } | ||
const withModifiers = (fn, modifiers) => { | ||
const cache = fn._withMods || (fn._withMods = {}); | ||
const cacheKey = modifiers.join("."); | ||
return cache[cacheKey] || (cache[cacheKey] = (event, ...args) => { | ||
return (event, ...args) => { | ||
for (let i = 0; i < modifiers.length; i++) { | ||
const guard = modifierGuards[modifiers[i]]; | ||
if (guard && guard(event, modifiers)) return; | ||
if (guard && guard(event, modifiers)) | ||
return; | ||
} | ||
return fn(event, ...args); | ||
}); | ||
}; | ||
}; | ||
@@ -1512,5 +1437,3 @@ const keyNames = { | ||
const withKeys = (fn, modifiers) => { | ||
const cache = fn._withKeys || (fn._withKeys = {}); | ||
const cacheKey = modifiers.join("."); | ||
return cache[cacheKey] || (cache[cacheKey] = (event) => { | ||
return (event) => { | ||
if (!("key" in event)) { | ||
@@ -1523,3 +1446,3 @@ return; | ||
} | ||
}); | ||
}; | ||
}; | ||
@@ -1553,3 +1476,4 @@ | ||
const container = normalizeContainer(containerOrSelector); | ||
if (!container) return; | ||
if (!container) | ||
return; | ||
const component = app._component; | ||
@@ -1560,3 +1484,3 @@ if (!isFunction(component) && !component.render && !component.template) { | ||
container.innerHTML = ""; | ||
const proxy = mount(container, false, resolveRootNamespace(container)); | ||
const proxy = mount(container, false, container instanceof SVGElement); | ||
if (container instanceof Element) { | ||
@@ -1580,3 +1504,3 @@ container.removeAttribute("k-cloak"); | ||
if (container) { | ||
return mount(container, true, resolveRootNamespace(container)); | ||
return mount(container, true, container instanceof SVGElement); | ||
} | ||
@@ -1586,13 +1510,5 @@ }; | ||
}; | ||
function resolveRootNamespace(container) { | ||
if (container instanceof SVGElement) { | ||
return "svg"; | ||
} | ||
if (typeof MathMLElement === "function" && container instanceof MathMLElement) { | ||
return "mathml"; | ||
} | ||
} | ||
function injectNativeTagCheck(app) { | ||
Object.defineProperty(app.config, "isNativeTag", { | ||
value: (tag) => isHTMLTag(tag) || isSVGTag(tag) || isMathMLTag(tag), | ||
value: (tag) => isHTMLTag(tag) || isSVGTag(tag), | ||
writable: false | ||
@@ -1618,3 +1534,3 @@ }); | ||
- For kdu-cli: see https://kdujs-cli.web.app/guide/webpack.html#modifying-options-of-a-loader | ||
- For lahm: pass it via @lahmjs/plugin-kdu options.`; | ||
- For wite: pass it via @witejs/plugin-kdu options.`; | ||
Object.defineProperty(app.config, "compilerOptions", { | ||
@@ -1621,0 +1537,0 @@ get() { |
{ | ||
"name": "@kdujs/runtime-dom-canary", | ||
"version": "3.20241118.0", | ||
"version": "3.20241125.0-minor.0", | ||
"description": "@kdujs/runtime-dom", | ||
@@ -13,16 +13,2 @@ "main": "index.js", | ||
], | ||
"exports": { | ||
".": { | ||
"types": "./dist/runtime-dom.d.ts", | ||
"node": { | ||
"production": "./dist/runtime-dom.cjs.prod.js", | ||
"development": "./dist/runtime-dom.cjs.js", | ||
"default": "./index.js" | ||
}, | ||
"module": "./dist/runtime-dom.esm-bundler.js", | ||
"import": "./dist/runtime-dom.esm-bundler.js", | ||
"require": "./index.js" | ||
}, | ||
"./*": "./*" | ||
}, | ||
"sideEffects": false, | ||
@@ -53,6 +39,6 @@ "buildOptions": { | ||
"dependencies": { | ||
"@kdujs/shared": "npm:@kdujs/shared-canary@3.20241118.0", | ||
"@kdujs/runtime-core": "npm:@kdujs/runtime-core-canary@3.20241118.0", | ||
"csstype": "^3.1.3" | ||
"@kdujs/shared": "npm:@kdujs/shared-canary@3.20241125.0-minor.0", | ||
"@kdujs/runtime-core": "npm:@kdujs/runtime-core-canary@3.20241125.0-minor.0", | ||
"csstype": "^3.1.2" | ||
} | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
17
984362
27378
2
+ Added@kdujs/reactivity-canary@3.20241125.0-minor.0(transitive)
+ Added@kdujs/runtime-core-canary@3.20241125.0-minor.0(transitive)
+ Added@kdujs/shared-canary@3.20241125.0-minor.0(transitive)
- Removed@kdujs/reactivity-canary@3.20241118.0(transitive)
- Removed@kdujs/runtime-core-canary@3.20241118.0(transitive)
- Removed@kdujs/shared-canary@3.20241118.0(transitive)
Updated@kdujs/runtime-core@npm:@kdujs/runtime-core-canary@3.20241125.0-minor.0
Updated@kdujs/shared@npm:@kdujs/shared-canary@3.20241125.0-minor.0
Updatedcsstype@^3.1.2