diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/Compiler.js | 13 | ||||
| -rw-r--r-- | src/directives.js | 6 | ||||
| -rw-r--r-- | src/scenario/dsl.js | 20 |
3 files changed, 27 insertions, 12 deletions
diff --git a/src/Compiler.js b/src/Compiler.js index 9263dc02..b0210247 100644 --- a/src/Compiler.js +++ b/src/Compiler.js @@ -112,9 +112,11 @@ Compiler.prototype = { templatize: function(element, elementIndex, priority){ var self = this, widget, + fn, directiveFns = self.directives, descend = true, directives = true, + elementName = nodeName(element), template, selfApi = { compile: bind(self, self.compile), @@ -138,12 +140,15 @@ Compiler.prototype = { eachAttribute(element, function(value, name){ if (!widget) { if (widget = self.widgets('@' + name)) { + element.addClass('ng-attr-widget'); widget = bind(selfApi, widget, value, element); } } }); if (!widget) { - if (widget = self.widgets(nodeName(element))) { + if (widget = self.widgets(elementName)) { + if (elementName.indexOf(':') > 0) + element.addClass('ng-widget'); widget = bind(selfApi, widget, element); } } @@ -179,7 +184,11 @@ Compiler.prototype = { }); }); eachAttribute(element, function(value, name){ - template.addInit((directiveFns[name]||noop).call(selfApi, value, element)); + fn = directiveFns[name]; + if (fn) { + element.addClass('ng-directive'); + template.addInit((directiveFns[name]).call(selfApi, value, element)); + } }); } // Process non text child nodes diff --git a/src/directives.js b/src/directives.js index a1fa4740..e21dca89 100644 --- a/src/directives.js +++ b/src/directives.js @@ -22,7 +22,8 @@ angularDirective("ng:eval", function(expression){ }; }); -angularDirective("ng:bind", function(expression){ +angularDirective("ng:bind", function(expression, element){ + element.addClass('ng-binding'); return function(element) { var lastValue = noop, lastError = noop; this.$onEval(function() { @@ -97,7 +98,8 @@ function compileBindTemplate(template){ return fn; } -angularDirective("ng:bind-template", function(expression){ +angularDirective("ng:bind-template", function(expression, element){ + element.addClass('ng-binding'); var templateFn = compileBindTemplate(expression); return function(element) { var lastValue; diff --git a/src/scenario/dsl.js b/src/scenario/dsl.js index 1ae26db8..47ec68c8 100644 --- a/src/scenario/dsl.js +++ b/src/scenario/dsl.js @@ -86,17 +86,21 @@ angular.scenario.dsl('using', function() { * binding(name) returns the value of a binding */ angular.scenario.dsl('binding', function() { + function contains(text, value) { + return text && text.indexOf(value) >=0; + } return function(name) { return this.addFutureAction("select binding '" + name + "'", function($window, $document, done) { - var element; - try { - element = $document.elements('[ng\\:bind-template*="{{$1}}"]', name); - } catch(e) { - if (e.type !== 'selector') - throw e; - element = $document.elements('[ng\\:bind="$1"]', name); + var elements = $document.elements('.ng-binding'); + for ( var i = 0; i < elements.length; i++) { + var element = new elements.init(elements[i]); + if (contains(element.attr('ng:bind'), name) >= 0 || + contains(element.attr('ng:bind-template'), name) >= 0) { + done(null, element.text()); + return; + } } - done(null, element.text()); + throw "Could not find binding: " + name; }); }; }); |
