Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// if this attribute is a boolean, make its value its key
if (typeof value === 'boolean') {
return [key, '=', `"${key}"`].join('')
}
if (value) {
// all values are expressions
value = common.scopedExpression(data, locationData, value)
// a class should not be empty
if (key === 'class' && !value) return ''
// data-* attributes should be escaped
if (key.indexOf('data-') === 0) {
if (typeof value !== 'string' && typeof value !== 'number') {
value = he.escape(JSON.stringify(value) + '')
} else {
value = '"' + value + '"'
}
} else {
value = JSON.stringify(value)
}
}
return [key, '=', value].join('')
})
attrs = attrs.filter(a => !!a)
function createIframe(rpcChannelId): HTMLIFrameElement {
const base = new URL("/sandbox", window.document.baseURI).href;
const html = `
`;
const iframe = document.createElement("iframe");
iframe.setAttribute("sandbox", "allow-scripts");
iframe.setAttribute("srcdoc", `${html}`);
// Edge doesn't support "srcdoc", it'll use a data url instead.
iframe.setAttribute("src", `data:text/html,${html}`);
iframe.style.display = "none";
document.body.appendChild(iframe);
return iframe;
}
if (getKey && !name) {
warnOnce(
`[vue-server-renderer] Components that implement "serverCacheKey" ` +
`must also define a unique "name" option.`
)
}
renderComponent(node, write, next, isRoot)
}
} else {
if (node.tag) {
renderElement(node, write, next, isRoot)
} else if (node.isComment) {
write(``, next)
} else {
write(node.raw ? node.text : escape(String(node.text)), next)
}
}
}
ontext: (text) => {
xhtml += `${he.escape(text)}`;
},
onclosetag: (tagname) => {
function htmlifyPlaintext(text) {
const escapedText = he.escape(text);
return `<pre class="nylas-plaintext">${escapedText}</pre>`;
}
}
if (getKey && !name) {
warnOnce(
`[vue-server-renderer] Components that implement "serverCacheKey" ` +
`must also define a unique "name" option.`
)
}
renderComponent(node, isRoot, context)
}
} else {
if (node.tag) {
renderElement(node, isRoot, context)
} else if (node.isComment) {
write(``, next)
} else {
write(node.raw ? node.text : escape(String(node.text)), next)
}
}
}
function renderNode (node, isRoot, context) {
if (isDef(node.componentOptions)) {
renderComponent(node, isRoot, context)
} else {
if (isDef(node.tag)) {
renderElement(node, isRoot, context)
} else if (isTrue(node.isComment)) {
context.write(
``,
context.next
)
} else {
context.write(
node.raw ? node.text : escape(String(node.text)),
context.next
)
}
}
}
export function renderAttr (key: string, value: string): string {
if (isBooleanAttr(key)) {
if (!isFalsyAttrValue(value)) {
return ` ${key}="${key}"`
}
} else if (isEnumeratedAttr(key)) {
return ` ${key}="${isFalsyAttrValue(value) || value === 'false' ? 'false' : 'true'}"`
} else if (!isFalsyAttrValue(value)) {
return ` ${key}="${typeof value === 'string' ? escape(value) : value}"`
}
return ''
}