aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/Compiler.js4
-rw-r--r--src/Scope.js4
-rw-r--r--src/directives.js2
-rw-r--r--src/filters.js2
-rw-r--r--src/parser.js14
-rw-r--r--src/service/route.js2
-rw-r--r--src/service/xhr.cache.js4
-rw-r--r--src/widgets.js4
8 files changed, 18 insertions, 18 deletions
diff --git a/src/Compiler.js b/src/Compiler.js
index 98e9630c..0001f8af 100644
--- a/src/Compiler.js
+++ b/src/Compiler.js
@@ -229,14 +229,14 @@ Compiler.prototype = {
template = new Template();
eachAttribute(element, function(value, name){
if (!widget) {
- if (widget = self.widgets('@' + name)) {
+ if ((widget = self.widgets('@' + name))) {
element.addClass('ng-attr-widget');
widget = bind(selfApi, widget, value, element);
}
}
});
if (!widget) {
- if (widget = self.widgets(elementName)) {
+ if ((widget = self.widgets(elementName))) {
if (elementNamespace)
element.addClass('ng-widget');
widget = bind(selfApi, widget, element);
diff --git a/src/Scope.js b/src/Scope.js
index b50d6273..6e90ea66 100644
--- a/src/Scope.js
+++ b/src/Scope.js
@@ -343,7 +343,7 @@ Scope.prototype = {
scope.$service('$exceptionHandler')(e);
}
}
- if (watchers = scope.$$watchers) {
+ if ((watchers = scope.$$watchers)) {
// process our watches
length = watchers.length;
while (length--) {
@@ -372,7 +372,7 @@ Scope.prototype = {
}
} while (scope !== this);
}
- } while (scope = next);
+ } while ((scope = next));
if(!(ttl--)) {
throw Error('100 $digest() iterations reached. Aborting!');
diff --git a/src/directives.js b/src/directives.js
index 937d0cca..54d7feb2 100644
--- a/src/directives.js
+++ b/src/directives.js
@@ -230,7 +230,7 @@ angularDirective("ng:bind", function(expression, element){
// If we are HTML than save the raw HTML data so that we don't
// recompute sanitization since it is expensive.
// TODO: turn this into a more generic way to compute this
- if (isHtml = (value instanceof HTML))
+ if ((isHtml = (value instanceof HTML)))
value = (html = value).html;
if (lastValue === value && lastError == error) return;
isDomElement = isElement(value);
diff --git a/src/filters.js b/src/filters.js
index f636b242..67e30046 100644
--- a/src/filters.js
+++ b/src/filters.js
@@ -610,7 +610,7 @@ angularFilter.linky = function(text) {
var writer = htmlSanitizeWriter(html);
var url;
var i;
- while (match = raw.match(LINKY_URL_REGEXP)) {
+ while ((match = raw.match(LINKY_URL_REGEXP))) {
// We can not end in these as they are sometimes found at the end of the sentence
url = match[0];
// if we did not match ftp/http/mailto then assume mailto
diff --git a/src/parser.js b/src/parser.js
index dadab1fb..5129f2f7 100644
--- a/src/parser.js
+++ b/src/parser.js
@@ -421,7 +421,7 @@ function parser(text, json){
var left = logicalOR();
var right;
var token;
- if (token = expect('=')) {
+ if ((token = expect('='))) {
if (!left.assign) {
throwError("implies assignment but [" +
text.substring(0, token.index) + "] can not be assigned to", token);
@@ -468,7 +468,7 @@ function parser(text, json){
function relational(){
var left = additive();
var token;
- if (token = expect('<', '>', '<=', '>=')) {
+ if ((token = expect('<', '>', '<=', '>='))) {
left = binaryFn(left, token.fn, relational());
}
return left;
@@ -477,7 +477,7 @@ function parser(text, json){
function additive(){
var left = multiplicative();
var token;
- while(token = expect('+','-')) {
+ while ((token = expect('+','-'))) {
left = binaryFn(left, token.fn, multiplicative());
}
return left;
@@ -486,7 +486,7 @@ function parser(text, json){
function multiplicative(){
var left = unary();
var token;
- while(token = expect('*','/','%')) {
+ while ((token = expect('*','/','%'))) {
left = binaryFn(left, token.fn, unary());
}
return left;
@@ -496,9 +496,9 @@ function parser(text, json){
var token;
if (expect('+')) {
return primary();
- } else if (token = expect('-')) {
+ } else if ((token = expect('-'))) {
return binaryFn(ZERO, token.fn, unary());
- } else if (token = expect('!')) {
+ } else if ((token = expect('!'))) {
return unaryFn(token.fn, unary());
} else {
return primary();
@@ -539,7 +539,7 @@ function parser(text, json){
}
}
var next;
- while (next = expect('(', '[', '.')) {
+ while ((next = expect('(', '[', '.'))) {
if (next.text === '(') {
primary = functionCall(primary);
} else if (next.text === '[') {
diff --git a/src/service/route.js b/src/service/route.js
index 9b4db0dd..5741c940 100644
--- a/src/service/route.js
+++ b/src/service/route.js
@@ -216,7 +216,7 @@ angularServiceInject('$route', function($location) {
// Match a route
forEach(routes, function(rParams, rPath) {
if (!pathParams) {
- if (pathParams = matcher($location.hashPath, rPath)) {
+ if ((pathParams = matcher($location.hashPath, rPath))) {
selectedRoute = rParams;
}
}
diff --git a/src/service/xhr.cache.js b/src/service/xhr.cache.js
index 256b936e..14051c40 100644
--- a/src/service/xhr.cache.js
+++ b/src/service/xhr.cache.js
@@ -52,7 +52,7 @@ angularServiceInject('$xhr.cache', function($xhr, $defer, $error, $log) {
if (method == 'GET') {
var data, dataCached;
- if (dataCached = cache.data[url]) {
+ if ((dataCached = cache.data[url])) {
if (sync) {
success(200, copy(dataCached.value));
@@ -64,7 +64,7 @@ angularServiceInject('$xhr.cache', function($xhr, $defer, $error, $log) {
return;
}
- if (data = inflight[url]) {
+ if ((data = inflight[url])) {
data.successes.push(success);
data.errors.push(error);
} else {
diff --git a/src/widgets.js b/src/widgets.js
index d9af21c9..30f7256a 100644
--- a/src/widgets.js
+++ b/src/widgets.js
@@ -877,7 +877,7 @@ angularWidget('select', function(element){
lastElement = null; // start at the begining
for(index = 0, length = optionGroup.length; index < length; index++) {
option = optionGroup[index];
- if (existingOption = existingOptions[index+1]) {
+ if ((existingOption = existingOptions[index+1])) {
// reuse elements
lastElement = existingOption.element;
if (existingOption.label !== option.label) {
@@ -1116,7 +1116,7 @@ angularWidget('ng:switch', function (element) {
this.$watch(watchExpr, function(scope, value) {
element.html('');
- if (selectedTemplate = casesTemplate[value] || defaultCaseTemplate) {
+ if ((selectedTemplate = casesTemplate[value] || defaultCaseTemplate)) {
changeCounter++;
if (childScope) childScope.$destroy();
childScope = scope.$new();
class="k">if (isHtml = (value instanceof HTML)) value = (html = value).html; if (lastValue === value && lastError == error) return; isDomElement = isElement(value); if (!isHtml && !isDomElement && isObject(value)) { value = toJson(value); } if (value != lastValue || error != lastError) { lastValue = value; lastError = error; elementError(element, NG_EXCEPTION, error); if (error) value = error; if (isHtml) { element.html(html.get()); } else if (isDomElement) { element.html(''); element.append(value); } else { element.text(value === _undefined ? '' : value); } } }, element); }; }); var bindTemplateCache = {}; function compileBindTemplate(template){ var fn = bindTemplateCache[template]; if (!fn) { var bindings = []; foreach(parseBindings(template), function(text){ var exp = binding(text); bindings.push(exp ? function(element){ var error, value = this.$tryEval(exp, function(e){ error = toJson(e); }); elementError(element, NG_EXCEPTION, error); return error ? error : value; } : function() { return text; }); }); bindTemplateCache[template] = fn = function(element){ var parts = [], self = this, oldElement = this.hasOwnProperty($$element) ? self.$element : _undefined; self.$element = element; for ( var i = 0; i < bindings.length; i++) { var value = bindings[i].call(self, element); if (isElement(value)) value = ''; else if (isObject(value)) value = toJson(value, true); parts.push(value); } self.$element = oldElement; return parts.join(''); }; } return fn; } angularDirective("ng:bind-template", function(expression, element){ element.addClass('ng-binding'); var templateFn = compileBindTemplate(expression); return function(element) { var lastValue; this.$onEval(function() { var value = templateFn.call(this, element); if (value != lastValue) { element.text(value); lastValue = value; } }, element); }; }); var REMOVE_ATTRIBUTES = { 'disabled':'disabled', 'readonly':'readOnly', 'checked':'checked' }; angularDirective("ng:bind-attr", function(expression){ return function(element){ var lastValue = {}; var updateFn = element.parent().data('$update'); this.$onEval(function(){ var values = this.$eval(expression); for(var key in values) { var value = compileBindTemplate(values[key]).call(this, element), specialName = REMOVE_ATTRIBUTES[lowercase(key)]; if (lastValue[key] !== value) { lastValue[key] = value; if (specialName) { if (element[specialName] = toBoolean(value)) { element.attr(specialName, value); } else { element.removeAttr(key); } (element.data('$validate')||noop)(); } else { element.attr(key, value); } this.$postEval(updateFn); } } }, element); }; }); angularWidget("@ng:non-bindable", noop); angularWidget("@ng:repeat", function(expression, element){ element.removeAttr('ng:repeat'); element.replaceWith(this.comment("ng:repeat: " + expression)); var template = this.compile(element); return function(reference){ var match = expression.match(/^\s*(.+)\s+in\s+(.*)\s*$/), lhs, rhs, valueIdent, keyIdent; if (! match) { throw "Expected ng:repeat in form of 'item in collection' but got '" + expression + "'."; } lhs = match[1]; rhs = match[2]; match = lhs.match(/^([\$\w]+)|\(([\$\w]+)\s*,\s*([\$\w]+)\)$/); if (!match) { throw "'item' in 'item in collection' should be identifier or (key, value) but got '" + keyValue + "'."; } valueIdent = match[3] || match[1]; keyIdent = match[2]; var children = [], currentScope = this; this.$onEval(function(){ var index = 0, childCount = children.length, childScope, lastElement = reference, collection = this.$tryEval(rhs, reference), is_array = isArray(collection); for ( var key in collection) { if (!is_array || collection.hasOwnProperty(key)) { if (index < childCount) { // reuse existing child childScope = children[index]; childScope[valueIdent] = collection[key]; if (keyIdent) childScope[keyIdent] = key; } else { // grow children childScope = template(quickClone(element), createScope(currentScope)); childScope[valueIdent] = collection[key]; if (keyIdent) childScope[keyIdent] = key; lastElement.after(childScope.$element); childScope.$index = index; childScope.$element.attr('ng:repeat-index', index); childScope.$init(); children.push(childScope); } childScope.$eval(); lastElement = childScope.$element; index ++; } } // shrink children while(children.length > index) { children.pop().$element.remove(); } }, reference); }; }); /* * A directive that allows creation of custom onclick handlers that are defined as angular * expressions and are compiled and executed within the current scope. * * Events that are handled via these handler are always configured not to propagate further. * * TODO: maybe we should consider allowing users to control event propagation in the future. */ angularDirective("ng:click", function(expression, element){ return function(element){ var self = this; element.bind('click', function(event){ self.$tryEval(expression, element); self.$root.$eval(); event.stopPropagation(); }); }; }); /** * Enables binding angular expressions to onsubmit events. * * Additionally it prevents the default action (which for form means sending the request to the * server and reloading the current page). */ angularDirective("ng:submit", function(expression, element) { return function(element) { var self = this; element.bind('submit', function(event) { self.$tryEval(expression, element); self.$root.$eval(); event.preventDefault(); }); }; }); angularDirective("ng:watch", function(expression, element){ return function(element){ var self = this; parser(expression).watch()({ addListener:function(watch, exp){ self.$watch(watch, function(){ return exp(self); }, element); } }); }; }); function ngClass(selector) { return function(expression, element){ var existing = element[0].className + ' '; return function(element){ this.$onEval(function(){ if (selector(this.$index)) { var value = this.$eval(expression); if (isArray(value)) value = value.join(' '); element[0].className = trim(existing + value); } }, element); }; }; } angularDirective("ng:class", ngClass(function(){return true;})); angularDirective("ng:class-odd", ngClass(function(i){return i % 2 === 0;})); angularDirective("ng:class-even", ngClass(function(i){return i % 2 === 1;})); angularDirective("ng:show", function(expression, element){ return function(element){ this.$onEval(function(){ element.css($display, toBoolean(this.$eval(expression)) ? '' : $none); }, element); }; }); angularDirective("ng:hide", function(expression, element){ return function(element){ this.$onEval(function(){ element.css($display, toBoolean(this.$eval(expression)) ? $none : ''); }, element); }; }); angularDirective("ng:style", function(expression, element){ return function(element){ var resetStyle = getStyle(element); this.$onEval(function(){ var style = this.$eval(expression) || {}, key, mergedStyle = {}; for(key in style) { if (resetStyle[key] === _undefined) resetStyle[key] = ''; mergedStyle[key] = style[key]; } for(key in resetStyle) { mergedStyle[key] = mergedStyle[key] || resetStyle[key]; } element.css(mergedStyle); }, element); }; });