Comparing version 1.9.3 to 1.9.4
@@ -292,10 +292,10 @@ let taskIdCounter = 1, | ||
let options; | ||
if ((arguments.length === 2 && typeof pFetcher === "object") || arguments.length === 1) { | ||
if (typeof pFetcher === "function") { | ||
source = pSource; | ||
fetcher = pFetcher; | ||
options = pOptions || {}; | ||
} else { | ||
source = true; | ||
fetcher = pSource; | ||
options = pFetcher || {}; | ||
} else { | ||
source = pSource; | ||
fetcher = pFetcher; | ||
options = pOptions || {}; | ||
} | ||
@@ -302,0 +302,0 @@ let pr = null, |
@@ -314,2 +314,48 @@ const equalFn = (a, b) => a === b; | ||
function escape(s, attr) { | ||
const t = typeof s; | ||
if (t !== "string") { | ||
if (t === "function") return escape(s()); | ||
if (Array.isArray(s)) { | ||
for (let i = 0; i < s.length; i++) s[i] = escape(s[i]); | ||
return s; | ||
} | ||
return s; | ||
} | ||
const delim = "<"; | ||
const escDelim = "<"; | ||
let iDelim = s.indexOf(delim); | ||
let iAmp = s.indexOf("&"); | ||
if (iDelim < 0 && iAmp < 0) return s; | ||
let left = 0, | ||
out = ""; | ||
while (iDelim >= 0 && iAmp >= 0) { | ||
if (iDelim < iAmp) { | ||
if (left < iDelim) out += s.substring(left, iDelim); | ||
out += escDelim; | ||
left = iDelim + 1; | ||
iDelim = s.indexOf(delim, left); | ||
} else { | ||
if (left < iAmp) out += s.substring(left, iAmp); | ||
out += "&"; | ||
left = iAmp + 1; | ||
iAmp = s.indexOf("&", left); | ||
} | ||
} | ||
if (iDelim >= 0) { | ||
do { | ||
if (left < iDelim) out += s.substring(left, iDelim); | ||
out += escDelim; | ||
left = iDelim + 1; | ||
iDelim = s.indexOf(delim, left); | ||
} while (iDelim >= 0); | ||
} else | ||
while (iAmp >= 0) { | ||
if (left < iAmp) out += s.substring(left, iAmp); | ||
out += "&"; | ||
left = iAmp + 1; | ||
iAmp = s.indexOf("&", left); | ||
} | ||
return left < s.length ? out + s.substring(left) : out; | ||
} | ||
function resolveSSRNode(node) { | ||
@@ -487,3 +533,3 @@ const t = typeof node; | ||
return { | ||
t: `<!--!$e${id}-->${resolveSSRNode(res)}<!--!$/e${id}-->` | ||
t: `<!--!$e${id}-->${resolveSSRNode(escape(res))}<!--!$/e${id}-->` | ||
}; | ||
@@ -494,9 +540,4 @@ } | ||
function createResource(source, fetcher, options = {}) { | ||
if (arguments.length === 2) { | ||
if (typeof fetcher === "object") { | ||
options = fetcher; | ||
fetcher = source; | ||
source = true; | ||
} | ||
} else if (arguments.length === 1) { | ||
if (typeof fetcher !== "function") { | ||
options = fetcher || {}; | ||
fetcher = source; | ||
@@ -683,3 +724,3 @@ source = true; | ||
if (suspenseComplete(value)) { | ||
done(resolveSSRNode(res)); | ||
done(resolveSSRNode(escape(res))); | ||
} | ||
@@ -725,3 +766,5 @@ } | ||
const res = { | ||
t: `<template id="pl-${id}"></template>${resolveSSRNode(props.fallback)}<!--pl-${id}-->` | ||
t: `<template id="pl-${id}"></template>${resolveSSRNode( | ||
escape(props.fallback) | ||
)}<!--pl-${id}-->` | ||
}; | ||
@@ -728,0 +771,0 @@ setHydrateContext(ctx); |
@@ -270,10 +270,10 @@ let taskIdCounter = 1, | ||
let options; | ||
if ((arguments.length === 2 && typeof pFetcher === "object") || arguments.length === 1) { | ||
if (typeof pFetcher === "function") { | ||
source = pSource; | ||
fetcher = pFetcher; | ||
options = pOptions || {}; | ||
} else { | ||
source = true; | ||
fetcher = pSource; | ||
options = pFetcher || {}; | ||
} else { | ||
source = pSource; | ||
fetcher = pFetcher; | ||
options = pOptions || {}; | ||
} | ||
@@ -280,0 +280,0 @@ let pr = null, |
{ | ||
"name": "solid-js", | ||
"description": "A declarative JavaScript library for building user interfaces.", | ||
"version": "1.9.3", | ||
"version": "1.9.4", | ||
"author": "Ryan Carniato", | ||
@@ -6,0 +6,0 @@ "license": "MIT", |
@@ -414,3 +414,3 @@ import { DEV as DEV$1, $PROXY, $TRACK, getListener, batch, createSignal } from "solid-js"; | ||
(previous[end] === target[newEnd] || | ||
(key && previous[start] && target[start] && previous[end][key] === target[newEnd][key])); | ||
(key && previous[end] && target[newEnd] && previous[end][key] === target[newEnd][key])); | ||
end--, newEnd-- | ||
@@ -417,0 +417,0 @@ ) { |
@@ -392,3 +392,3 @@ import { $PROXY, $TRACK, getListener, batch, createSignal } from "solid-js"; | ||
(previous[end] === target[newEnd] || | ||
(key && previous[start] && target[start] && previous[end][key] === target[newEnd][key])); | ||
(key && previous[end] && target[newEnd] && previous[end][key] === target[newEnd][key])); | ||
end--, newEnd-- | ||
@@ -395,0 +395,0 @@ ) { |
@@ -657,6 +657,6 @@ import { sharedConfig, createRoot, splitProps } from "solid-js"; | ||
const last = html.indexOf(`<!--!$/${id}-->`, first + placeholder.length); | ||
html = html.replace( | ||
html.slice(first, last + placeholder.length + 1), | ||
resolveSSRNode(payloadFn()) | ||
); | ||
html = | ||
html.slice(0, first) + | ||
resolveSSRNode(escape(payloadFn())) + | ||
html.slice(last + placeholder.length + 1); | ||
}, | ||
@@ -981,3 +981,3 @@ serialize(id, p, wait) { | ||
function useAssets(fn) { | ||
sharedConfig.context.assets.push(() => resolveSSRNode(fn())); | ||
sharedConfig.context.assets.push(() => resolveSSRNode(escape(fn()))); | ||
} | ||
@@ -1028,3 +1028,5 @@ function getAssets() { | ||
for (let i = 0, len = assets.length; i < len; i++) out += assets[i](); | ||
return html.replace(`</head>`, out + `</head>`); | ||
const index = html.indexOf("</head>"); | ||
if (index === -1) return html; | ||
return html.slice(0, index) + out + html.slice(index); | ||
} | ||
@@ -1031,0 +1033,0 @@ function injectScripts(html, scripts, nonce) { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
888878
26903
76