Skip to content

Commit

Permalink
Fix the lit-html marker length to be consistently 9 characters. (#4570)
Browse files Browse the repository at this point in the history
This was always how we intended it to behave, and since it didn't have a reliable length before this change this should be safe.
  • Loading branch information
rictic committed Apr 2, 2024
1 parent 23121c2 commit bd88137
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
7 changes: 7 additions & 0 deletions .changeset/young-roses-fly.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'lit-html': patch
'lit': patch
'lit-element': patch
---

Fix the lit-html marker length to be consistently 9 characters.
2 changes: 1 addition & 1 deletion packages/lit-html/src/lit-html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ const boundAttributeSuffix = '$lit$';
// a valid element name and attribute name. We don't support dynamic names (yet)
// but this at least ensures that the parse tree is closer to the template
// intention.
const marker = `lit$${String(Math.random()).slice(9)}$`;
const marker = `lit$${Math.random().toFixed(9).slice(2)}$`;

// String used to tell if a comment is a marker comment
const markerMatch = '?' + marker;
Expand Down
4 changes: 2 additions & 2 deletions scripts/check-size.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import * as fs from 'fs';
// it's likely that we'll ask you to investigate ways to reduce the size.
//
// In either case, update the size here and push a new commit to your PR.
const expectedLitCoreSize = 15437;
const expectedLitHtmlSize = 7252;
const expectedLitCoreSize = 15443;
const expectedLitHtmlSize = 7258;

const litCoreSrc = fs.readFileSync('packages/lit/lit-core.min.js', 'utf8');
const litCoreSize = fs.readFileSync('packages/lit/lit-core.min.js').byteLength;
Expand Down

0 comments on commit bd88137

Please sign in to comment.