Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@vaadin/vaadin-template-renderer

Package Overview
Dependencies
Maintainers
19
Versions
213
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vaadin/vaadin-template-renderer - npm Package Compare versions

Comparing version 21.0.0-alpha0.b163d3a8c to 21.0.0-alpha1

4

package.json
{
"name": "@vaadin/vaadin-template-renderer",
"version": "21.0.0-alpha0.b163d3a8c",
"version": "21.0.0-alpha1",
"description": "vaadin-template-renderer",

@@ -33,3 +33,3 @@ "main": "vaadin-template-renderer.js",

},
"gitHead": "e1ed53b0be7b77493e3a23a076f4e47c16674dbd"
"gitHead": "8542c7dadc4c86e454a48613f0f2d027dcb5aa86"
}

@@ -15,45 +15,52 @@ import { PolymerElement } from '@polymer/polymer';

static get properties() {
return {
__template: Object,
__TemplateClass: Object,
__templateInstance: Object
};
constructor() {
super();
this.__template = null;
this.__TemplateClass = null;
this.__templateInstances = new Set();
}
/**
* @public
*/
render(element) {
// TODO: Support creating multiple instances of the template
if (!this.__templateInstance) {
this.__createTemplateInstance();
render(element, properties = {}) {
// If the template instance exists and has been instantiated by this templatizer,
// it only re-renders the instance with the new properties.
if (this.__templateInstances.has(element.__templateInstance)) {
element.__templateInstance.setProperties(properties);
return;
}
element.__templateInstance = this.__templateInstance;
element.replaceChildren(this.__templateInstance.root);
}
// Otherwise, it instantiates a new template instance
// with the given properties and then renders the result to the element
const templateInstance = this.__createTemplateInstance(properties);
element.innerHTML = '';
element.__templateInstance = templateInstance;
element.appendChild(templateInstance.root);
}
/**
* @private
*/
__createTemplateInstance() {
this.__createTemplateClass();
__createTemplateInstance(properties) {
this.__createTemplateClass(properties);
this.__templateInstance = new this.__TemplateClass();
const instance = new this.__TemplateClass(properties);
this.__templateInstances.add(instance);
return instance;
}
/**
* @private
*/
__createTemplateClass() {
if (this.__TemplateClass) {
return;
}
__createTemplateClass(properties) {
if (this.__TemplateClass) return;
const instanceProps = Object.keys(properties).reduce((accum, key) => {
return { ...accum, [key]: true };
}, {});
this.__TemplateClass = templatize(this.__template, this, {
// This property prevents the template instance properties
// from passing into the `forwardHostProp` callback
instanceProps,
// When changing a property of the data host component, this callback forwards
// the changed property to the template instances so that cause their re-rendering.
forwardHostProp(prop, value) {
if (this.__templateInstance) {
this.__templateInstance.forwardHostProp(prop, value);
}
this.__templateInstances.forEach((instance) => {
instance.forwardHostProp(prop, value);
});
}

@@ -60,0 +67,0 @@ });

@@ -7,5 +7,5 @@ import './vaadin-template-renderer-templatizer.js';

return (root) => {
return (root, _owner, model) => {
template.__templatizer = templatizer;
template.__templatizer.render(root);
template.__templatizer.render(root, model);
};

@@ -12,0 +12,0 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc