/** * OC Bind component for manual binding of an element on the page */ import KinisiteBind from "../kinisite-bind"; export default class KBind extends HTMLElement { // Initialised flag private _initialised = false; private _bind: any; private _model: any = {}; constructor() { super(); if (this.isConnected) this._init(); } /** * Set a model value * * @param key * @param value */ public setModelValue(key: any, value: any) { this._model[key] = value; if (this._initialised) KinisiteBind.addNewProperty(this._bind.model, key, value); } // Listen for attachment events connectedCallback() { this._init(); } // Initialise function - only called once private _init() { if (!this._initialised) { this._initialised = true; // Ensure template delimiters are passed correctly but assume parent config let config = {...KinisiteBind.Kinibind.config, templateDelimiters: ['{', '}']}; this._bind = new KinisiteBind(this, this._model, config); } } }