Skip to content

Commit

Permalink
Remove private Lit 2 migration helpers (#2828)
Browse files Browse the repository at this point in the history
Remove private Lit 2 migration helpers that are no longer depended on.

Removed: `INTERNAL` and `clearContainerForLit2MigrationOnly`.
  • Loading branch information
AndrewJakubowicz committed May 5, 2022
1 parent c30fdf7 commit b3b6bc3
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 59 deletions.
6 changes: 6 additions & 0 deletions .changeset/swift-months-double.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'lit-html': patch
'lit': patch
---

Remove private Lit 2 migration helpers: `INTERNAL` and `clearContainerForLit2MigrationOnly`. This logic is no longer depended on.
33 changes: 0 additions & 33 deletions packages/lit-html/src/lit-html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,13 +207,6 @@ const debugLogEvent = DEV_MODE
// called.
let debugLogRenderId = 0;

/**
* `true` if we're building for google3 with temporary back-compat helpers.
* This export is not present in prod builds.
* @internal
*/
export const INTERNAL = true;

let issueWarning: (code: string, warning: string) => void;

if (DEV_MODE) {
Expand Down Expand Up @@ -614,18 +607,6 @@ export interface RenderOptions {
isConnected?: boolean;
}

/**
* Internally we can export this interface and change the type of
* render()'s options.
*/
interface InternalRenderOptions extends RenderOptions {
/**
* An internal-only migration flag
* @internal
*/
clearContainerForLit2MigrationOnly?: boolean;
}

/**
* Renders a value, usually a lit-html TemplateResult, to the container.
* @param value
Expand Down Expand Up @@ -659,20 +640,6 @@ export const render = (
});
if (part === undefined) {
const endNode = options?.renderBefore ?? null;
// Internal modification: don't clear container to match lit-html 2.0
if (
INTERNAL &&
(options as InternalRenderOptions)?.clearContainerForLit2MigrationOnly ===
true
) {
let n = container.firstChild;
// Clear only up to the `endNode` aka `renderBefore` node.
while (n && n !== endNode) {
const next = n.nextSibling;
n.remove();
n = next;
}
}
// This property needs to remain unminified.
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(partOwnerNode as any)['_$litPart$'] = part = new ChildPart(
Expand Down
23 changes: 0 additions & 23 deletions packages/lit-html/src/test/lit-html_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import {
Part,
CompiledTemplate,
} from '../lit-html.js';
import * as litHtmlLib from '../lit-html.js';

import {
directive,
Expand Down Expand Up @@ -49,10 +48,6 @@ const isIe = ua.indexOf('Trident/') > 0;
// We don't have direct access to DEV_MODE, but this is a good enough
// proxy.
const DEV_MODE = render.setSanitizer != null;
/**
* litHtmlLib.INTERNAL is not exported in prod mode
*/
const INTERNAL = litHtmlLib.INTERNAL === true;

class FireEventDirective extends Directive {
render() {
Expand Down Expand Up @@ -3183,22 +3178,4 @@ suite('lit-html', () => {
assertNoWarning();
});
});

suite('internal', () => {
test('clearContainerForLit2MigrationOnly', () => {
const clearedHtml = `<div>TEST 1</div><div>TEST 2</div>`;
const remainingHtml = `<div class="renderBefore">REMAIN 1</div><div>REMAIN 2</div>`;
container.innerHTML = `${clearedHtml}${remainingHtml}`;
render(html`<p>HELLO</p>`, container, {
clearContainerForLit2MigrationOnly: true,
renderBefore: container.querySelector('.renderBefore'),
} as RenderOptions);
assert.equal(
stripExpressionComments(container.innerHTML),
INTERNAL
? `<p>HELLO</p>${remainingHtml}`
: `${clearedHtml}<p>HELLO</p>${remainingHtml}`
);
});
});
});
3 changes: 0 additions & 3 deletions rollup-common.js
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,6 @@ export function litProdConfig({
'const ENABLE_EXTRA_SECURITY_HOOKS = false',
'const ENABLE_SHADYDOM_NOPATCH = true':
'const ENABLE_SHADYDOM_NOPATCH = false',
'export const INTERNAL = true': 'const INTERNAL = false',
}),
// This plugin automatically composes the existing TypeScript -> raw JS
// sourcemap with the raw JS -> minified JS one that we're generating here.
Expand Down Expand Up @@ -453,12 +452,10 @@ const litMonoBundleConfig = ({
'const ENABLE_EXTRA_SECURITY_HOOKS = false',
'const ENABLE_SHADYDOM_NOPATCH = true':
'const ENABLE_SHADYDOM_NOPATCH = false',
'export const INTERNAL = true': 'const INTERNAL = false',
// For downleveled ES5 build of polyfill-support
'var DEV_MODE = true': 'var DEV_MODE = false',
'var ENABLE_EXTRA_SECURITY_HOOKS = true':
'var ENABLE_EXTRA_SECURITY_HOOKS = false',
'var INTERNAL = true': 'var INTERNAL = false',
'var ENABLE_SHADYDOM_NOPATCH = true':
'var ENABLE_SHADYDOM_NOPATCH = false',
}),
Expand Down

0 comments on commit b3b6bc3

Please sign in to comment.