Skip to content

Commit

Permalink
special case value/checked props for spread assignment
Browse files Browse the repository at this point in the history
  • Loading branch information
ryansolid committed Jan 8, 2024
1 parent a9abd97 commit c008e34
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions packages/dom-expressions/src/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ export function template(html, isCE, isSVG) {
let node;
const create = () => {
if ("_DX_DEV_" && sharedConfig.context)
throw new Error("Failed attempt to create new DOM elements during hydration. Check that the libraries you are using support hydration.");
throw new Error(
"Failed attempt to create new DOM elements during hydration. Check that the libraries you are using support hydration."
);
const t = document.createElement("template");
t.innerHTML = html;
return isSVG ? t.content.firstChild.firstChild : t.content.firstChild;
Expand Down Expand Up @@ -223,8 +225,8 @@ export function assign(node, props, isSVG, skipChildren, prevProps = {}, skipRef
export function hydrate(code, element, options = {}) {
sharedConfig.completed = globalThis._$HY.completed;
sharedConfig.events = globalThis._$HY.events;
sharedConfig.load = (id) => globalThis._$HY.r[id];
sharedConfig.has = (id) => id in globalThis._$HY.r;
sharedConfig.load = id => globalThis._$HY.r[id];
sharedConfig.has = id => id in globalThis._$HY.r;
sharedConfig.gather = root => gatherHydratable(element, root);
sharedConfig.registry = new Map();
sharedConfig.context = {
Expand Down Expand Up @@ -306,7 +308,7 @@ function assignProp(node, prop, value, prev, isSVG, skipRef) {
let isCE, isProp, isChildProp, propAlias, forceProp;
if (prop === "style") return style(node, value, prev);
if (prop === "classList") return classList(node, value, prev);
if (value === prev) return prev;
if (value === prev && (prop !== "value" || prop !== "checked")) return prev;
if (prop === "ref") {
if (!skipRef) value(node);
} else if (prop.slice(0, 3) === "on:") {
Expand Down Expand Up @@ -439,7 +441,7 @@ function insertExpression(parent, value, current, marker, unwrapArray) {
let node = array[0];
let nodes = [node];
while ((node = node.nextSibling) !== marker) nodes.push(node);
return current = nodes;
return (current = nodes);
}
if (array.length === 0) {
current = cleanChildren(parent, current, marker);
Expand Down Expand Up @@ -555,4 +557,4 @@ export const RequestContext = Symbol();
// deprecated
export function innerHTML(parent, content) {
!sharedConfig.context && (parent.innerHTML = content);
}
}

0 comments on commit c008e34

Please sign in to comment.