Skip to content

Commit

Permalink
Fix sf-click error
Browse files Browse the repository at this point in the history
  • Loading branch information
StefansArya committed Apr 2, 2019
1 parent 57d0fc0 commit 3f1f51a
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/sf-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ sf.controller = new function(){
return;
}

name = name.sf$component === void 0 ? name.getAttribute('sf-controller') : name.sf$component;
name = name.sf$component === void 0? name.getAttribute('sf-controller') : name.sf$component;

// Initialize it first
if(name !== void 0 && !self.active[name])
Expand All @@ -73,12 +73,13 @@ sf.controller = new function(){
}

var model = $.parent(element, '[sf-controller]');
model = model.sf$component === void 0? model.getAttribute('sf-controller') : model;
model = model.sf$component === void 0 ? model.getAttribute('sf-controller') : model;
var _modelScope = sf.model.root[model];

if(!sf.model.root[model])
if(_modelScope === void 0)
throw "Couldn't find model for "+model+" that was called from sf-click";

var modelKeys = sf.model.modelKeys(sf.model.root[model]).join('|');
var modelKeys = sf.model.modelKeys(_modelScope).join('|');
script = avoidQuotes(script, function(script_){
return script_.replace(RegExp(sf.regex.strictVar+'('+modelKeys+')\\b', 'g'), function(full, matched){
return '_modelScope.'+matched;
Expand Down

0 comments on commit 3f1f51a

Please sign in to comment.