Skip to content

Commit

Permalink
Merge pull request #371 from titoBouzout/ssrattrprop
Browse files Browse the repository at this point in the history
ssr attribute inlining updates
  • Loading branch information
ryansolid authored Oct 21, 2024
2 parents 9be86dd + 80b9efe commit 0b443c8
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions packages/dom-expressions/src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -380,8 +380,18 @@ export function ssrElement(tag, props, children, needsId) {
} else if (BooleanAttributes.has(prop)) {
if (value) result += prop;
else continue;
} else if (value == undefined || prop === "ref" || prop.slice(0, 2) === "on") {
} else if (
value == undefined ||
prop === "ref" ||
prop.slice(0, 2) === "on" ||
prop.slice(0, 5) === "prop:"
) {
continue;
} else if (prop.slice(0, 5) === "bool:") {
if (!value) continue;
result += escape(prop.slice(5));
} else if (prop.slice(0, 5) === "attr:") {
result += `${escape(prop.slice(5))}="${escape(value, true)}"`;
} else {
result += `${Aliases[prop] || escape(prop)}="${escape(value, true)}"`;
}
Expand Down Expand Up @@ -606,9 +616,7 @@ export function Assets(props) {
}

/* istanbul ignore next */
/**
* @deprecated Replaced by renderToStream
*/
/** @deprecated Replaced by renderToStream */
export function pipeToNodeWritable(code, writable, options = {}) {
if (options.onReady) {
options.onCompleteShell = ({ write }) => {
Expand All @@ -625,9 +633,7 @@ export function pipeToNodeWritable(code, writable, options = {}) {
}

/* istanbul ignore next */
/**
* @deprecated Replaced by renderToStream
*/
/** @deprecated Replaced by renderToStream */
export function pipeToWritable(code, writable, options = {}) {
if (options.onReady) {
options.onCompleteShell = ({ write }) => {
Expand All @@ -644,9 +650,7 @@ export function pipeToWritable(code, writable, options = {}) {
}

/* istanbul ignore next */
/**
* @deprecated Replaced by ssrElement
*/
/** @deprecated Replaced by ssrElement */
export function ssrSpread(props, isSVG, skipChildren) {
let result = "";
if (props == null) return result;
Expand Down Expand Up @@ -679,17 +683,13 @@ export function ssrSpread(props, isSVG, skipChildren) {
prop.slice(0, 5) === "prop:"
) {
continue;
} else if (prop.slice(0, 5) === "bool:") {
if (!value) continue;
result += escape(prop.slice(5));
} else if (prop.slice(0, 5) === "attr:") {
result += `${escape(prop.slice(5))}="${escape(value, true)}"`;
} else {
// bool:
if (prop.slice(0, 5) === "bool:") {
if (!value) continue;
prop = prop.slice(5);
result += `${escape(prop)}`;
} else {
// attr:
if (prop.slice(0, 5) === "attr:") prop = prop.slice(5);
result += `${Aliases[prop] || escape(prop)}="${escape(value, true)}"`;
}
result += `${Aliases[prop] || escape(prop)}="${escape(value, true)}"`;
}
if (i !== keys.length - 1) result += " ";
}
Expand Down

0 comments on commit 0b443c8

Please sign in to comment.