@lit-labs/ssr
Advanced tools
Comparing version 3.2.1 to 3.2.2
@@ -151,3 +151,3 @@ /** | ||
['title', ['*']], | ||
['translate', [ /*'*'*/]], | ||
['translate', [ /*'*'*/]], //TODO(kschaaf): 'translate' boolean property maps to 'yes'/'no' | ||
['type', ['button', 'input', /*'command',*/ 'embed', 'object', 'script', 'source', 'style', /*'menu'*/]], | ||
@@ -154,0 +154,0 @@ [['usemap', 'useMap'], ['img', 'input', 'object']], |
@@ -6,3 +6,3 @@ /// <reference lib="dom" /> | ||
import { _$LH } from 'lit-html/private-ssr-support.js'; | ||
const { getTemplateHtml, marker, markerMatch, boundAttributeSuffix, overrideDirectiveResolve, setDirectiveClass, getAttributePartCommittedValue, resolveDirective, AttributePart, PropertyPart, BooleanAttributePart, EventPart, connectedDisconnectable, isIterable, } = _$LH; | ||
const { getTemplateHtml, marker, markerMatch, boundAttributeSuffix, patchDirectiveResolve, getAttributePartCommittedValue, resolveDirective, AttributePart, PropertyPart, BooleanAttributePart, EventPart, connectedDisconnectable, isIterable, } = _$LH; | ||
import { digestForTemplateResult } from '@lit-labs/ssr-client'; | ||
@@ -16,22 +16,15 @@ import { getElementRenderer, } from './element-renderer.js'; | ||
import { isHydratable } from './server-template.js'; | ||
const patchedDirectiveCache = new WeakMap(); | ||
function ssrResolve(_part, values) { | ||
// Since the return value may also be a directive result in the case of nested | ||
// directives, we may need to patch that as well. | ||
return patchIfDirective(this.render(...values)); | ||
} | ||
/** | ||
* Looks for values of type `DirectiveResult` and replaces its Directive class | ||
* with a subclass that calls `render` rather than `update` | ||
* Looks for values of type `DirectiveResult` and patches its Directive class | ||
* such that it calls `render` rather than `update`. | ||
*/ | ||
const patchIfDirective = (value) => { | ||
// This property needs to remain unminified. | ||
const directiveCtor = getDirectiveClass(value); | ||
if (directiveCtor !== undefined) { | ||
let patchedCtor = patchedDirectiveCache.get(directiveCtor); | ||
if (patchedCtor === undefined) { | ||
patchedCtor = overrideDirectiveResolve(directiveCtor, (directive, values) => { | ||
// Since the return value may also be a directive result in the case of | ||
// nested directives, we may need to patch that as well | ||
return patchIfDirective(directive.render(...values)); | ||
}); | ||
patchedDirectiveCache.set(directiveCtor, patchedCtor); | ||
} | ||
// This property needs to remain unminified. | ||
setDirectiveClass(value, patchedCtor); | ||
patchDirectiveResolve(directiveCtor, ssrResolve); | ||
} | ||
@@ -56,2 +49,8 @@ return value; | ||
/** | ||
* Any of these top level tags will be removed by parse5's `parseFragment` and | ||
* will cause part errors if there are any part bindings. For only the `html`, | ||
* `head`, and `body` tags, we use a page-level template `parse`. | ||
*/ | ||
const REGEXP_TEMPLATE_HAS_TOP_LEVEL_PAGE_TAG = /^(\s|<!--[^(-->)]*-->)*(<(!doctype|html|head|body))/i; | ||
/** | ||
* For a given TemplateResult, generates and/or returns a cached list of opcodes | ||
@@ -118,3 +117,3 @@ * for the associated Template. Opcodes are designed to allow emitting | ||
*/ | ||
const getTemplateOpcodes = (result, isServerTemplate = false) => { | ||
const getTemplateOpcodes = (result) => { | ||
const template = templateCache.get(result.strings); | ||
@@ -130,2 +129,6 @@ if (template !== undefined) { | ||
const hydratable = isHydratable(result); | ||
const htmlString = String(html); | ||
// Only server templates can use top level document tags such as `<html>`, | ||
// `<body>`, and `<head>`. | ||
const isPageLevelTemplate = !hydratable && REGEXP_TEMPLATE_HAS_TOP_LEVEL_PAGE_TAG.test(htmlString); | ||
/** | ||
@@ -136,6 +139,6 @@ * The html string is parsed into a parse5 AST with source code information | ||
* | ||
* Server Templates need to use `parse` as they may contain document tags such | ||
* Server Templates may need to use `parse` as they may contain document tags such | ||
* as `<html>`. | ||
*/ | ||
const ast = (isServerTemplate ? parse : parseFragment)(String(html), { | ||
const ast = (isPageLevelTemplate ? parse : parseFragment)(htmlString, { | ||
sourceCodeLocationInfo: true, | ||
@@ -457,3 +460,3 @@ }); | ||
const hydratable = isHydratable(result); | ||
const ops = getTemplateOpcodes(result, !hydratable); | ||
const ops = getTemplateOpcodes(result); | ||
/* The next value in result.values to render */ | ||
@@ -460,0 +463,0 @@ let partIndex = 0; |
{ | ||
"name": "@lit-labs/ssr", | ||
"type": "module", | ||
"version": "3.2.1", | ||
"version": "3.2.2", | ||
"publishConfig": { | ||
@@ -227,11 +227,11 @@ "access": "public" | ||
"dependencies": { | ||
"@lit-labs/ssr-client": "^1.1.4", | ||
"@lit-labs/ssr-dom-shim": "^1.1.2", | ||
"@lit/reactive-element": "^1.6.1 || ^2.0.0", | ||
"@lit-labs/ssr-client": "^1.1.7", | ||
"@lit-labs/ssr-dom-shim": "^1.2.0", | ||
"@lit/reactive-element": "^2.0.4", | ||
"@parse5/tools": "^0.3.0", | ||
"@types/node": "^16.0.0", | ||
"enhanced-resolve": "^5.10.0", | ||
"lit": "^3.1.0", | ||
"lit-element": "^3.3.0 || ^4.0.0", | ||
"lit-html": "^3.1.0", | ||
"lit": "^3.1.2", | ||
"lit-element": "^4.0.4", | ||
"lit-html": "^3.1.2", | ||
"node-fetch": "^3.2.8", | ||
@@ -238,0 +238,0 @@ "parse5": "^7.1.1" |
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
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
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
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
264008
2419
Updated@lit-labs/ssr-client@^1.1.7
Updated@lit/reactive-element@^2.0.4
Updatedlit@^3.1.2
Updatedlit-element@^4.0.4
Updatedlit-html@^3.1.2