first commit
This commit is contained in:
31
node_modules/lit-html/development/directives/template-content.js
generated
vendored
Normal file
31
node_modules/lit-html/development/directives/template-content.js
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2020 Google LLC
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
import { noChange } from '../lit-html.js';
|
||||
import { directive, Directive, PartType } from '../directive.js';
|
||||
class TemplateContentDirective extends Directive {
|
||||
constructor(partInfo) {
|
||||
super(partInfo);
|
||||
if (partInfo.type !== PartType.CHILD) {
|
||||
throw new Error('templateContent can only be used in child bindings');
|
||||
}
|
||||
}
|
||||
render(template) {
|
||||
if (this._previousTemplate === template) {
|
||||
return noChange;
|
||||
}
|
||||
this._previousTemplate = template;
|
||||
return document.importNode(template.content, true);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Renders the content of a template element as HTML.
|
||||
*
|
||||
* Note, the template should be developer controlled and not user controlled.
|
||||
* Rendering a user-controlled template with this directive
|
||||
* could lead to cross-site-scripting vulnerabilities.
|
||||
*/
|
||||
export const templateContent = directive(TemplateContentDirective);
|
||||
//# sourceMappingURL=template-content.js.map
|
Reference in New Issue
Block a user