Skip to content

Commit

Permalink
Fix crash if binding is not found
Browse files Browse the repository at this point in the history
  • Loading branch information
kachurun committed Jun 8, 2021
1 parent 9835318 commit f2da571
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/binding.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@ export default function create(root, binding, templateTagOffset) {
const { selector, type, redundantAttribute, expressions } = binding
// find the node to apply the bindings
const node = selector ? root.querySelector(selector) : root

if (!node) return null

// remove eventually additional attributes created only to select this node
if (redundantAttribute) node.removeAttribute(redundantAttribute)

const bindingExpressions = expressions || []
// init the binding
return (bindings[type] || bindings[SIMPLE])(
Expand Down
2 changes: 1 addition & 1 deletion src/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export const TemplateChunk = Object.freeze({
this.el,
binding,
templateTagOffset
))
)).filter(binding => binding)
this.bindings.forEach(b => b.mount(scope, parentScope))

// store the template meta properties
Expand Down

0 comments on commit f2da571

Please sign in to comment.