Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function renderToIDom(html) {
var ast = parse(html);
if (Array.isArray(ast)) {
ast.forEach(renderAstNode);
} else {
renderAstNode(ast);
}
};
renderWithTemplate: function (data) {
var newTree = this.renderTemplateToVdom(data);
var isBackbone = typeof this.setElement === 'function';
var isFirstRender;
//view was initialized with an el, not yet rendered
if (!this.tree && this.el) {
this.tree = this.astToVdom(parse(this.el.outerHTML));
isFirstRender = true;
}
//first render
if (!this.el) {
isFirstRender = true;
var el = createElement(newTree);
this.tree = newTree;
if (isBackbone) {
this.el.appendChild(el);
this._backboneEl = el;
} else {
this.el = el;
}
//subsequent renders
} else {
renderTemplateToVdom: function (data) {
var renderedTemplate;
if (isString(this.template)) {
renderedTemplate = this.template;
} else {
renderedTemplate = this.template(data || this);
}
return this.astToVdom(parse(renderedTemplate.trim()));
},