@lit-labs/ssr
Advanced tools
Comparing version 3.2.0 to 3.2.1
@@ -10,3 +10,3 @@ /// <reference lib="dom" /> | ||
import { escapeHtml } from './util/escape-html.js'; | ||
import { parseFragment } from 'parse5'; | ||
import { parseFragment, parse } from 'parse5'; | ||
import { isElementNode, isCommentNode, traverse, isTextNode, isTemplateNode, } from '@parse5/tools'; | ||
@@ -116,3 +116,3 @@ import { isRenderLightDirective } from '@lit-labs/ssr-client/directives/render-light.js'; | ||
*/ | ||
const getTemplateOpcodes = (result) => { | ||
const getTemplateOpcodes = (result, isServerTemplate = false) => { | ||
const template = templateCache.get(result.strings); | ||
@@ -122,3 +122,2 @@ if (template !== undefined) { | ||
} | ||
// The property '_$litType$' needs to remain unminified. | ||
const [html, attrNames] = getTemplateHtml(result.strings, | ||
@@ -134,4 +133,7 @@ // SVG TemplateResultType functionality is only required on the client, | ||
* while walking the AST. | ||
* | ||
* Server Templates need to use `parse` as they may contain document tags such | ||
* as `<html>`. | ||
*/ | ||
const ast = parseFragment(String(html), { | ||
const ast = (isServerTemplate ? parse : parseFragment)(String(html), { | ||
sourceCodeLocationInfo: true, | ||
@@ -258,6 +260,2 @@ }); | ||
const strings = attr.value.split(marker); | ||
// We store the case-sensitive name from `attrNames` (generated | ||
// while parsing the template strings); note that this assumes | ||
// parse5 attribute ordering matches string ordering | ||
const name = attrNames[attrIndex++]; | ||
const attrSourceLocation = node.sourceCodeLocation.attrs[attr.name]; | ||
@@ -268,2 +266,6 @@ const attrNameStartOffset = attrSourceLocation.startOffset; | ||
if (isAttrBinding) { | ||
// We store the case-sensitive name from `attrNames` (generated | ||
// while parsing the template strings); note that this assumes | ||
// parse5 attribute ordering matches string ordering | ||
const name = attrNames[attrIndex++]; | ||
const [, prefix, caseSensitiveName] = /([.?@])?(.*)/.exec(name); | ||
@@ -455,3 +457,3 @@ if (!hydratable) { | ||
const hydratable = isHydratable(result); | ||
const ops = getTemplateOpcodes(result); | ||
const ops = getTemplateOpcodes(result, !hydratable); | ||
/* The next value in result.values to render */ | ||
@@ -458,0 +460,0 @@ let partIndex = 0; |
{ | ||
"name": "@lit-labs/ssr", | ||
"type": "module", | ||
"version": "3.2.0", | ||
"version": "3.2.1", | ||
"publishConfig": { | ||
@@ -6,0 +6,0 @@ "access": "public" |
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
262431
2416