diff options
Diffstat (limited to 'src/Angular.js')
| -rw-r--r-- | src/Angular.js | 54 |
1 files changed, 36 insertions, 18 deletions
diff --git a/src/Angular.js b/src/Angular.js index 3970f762..1c75a063 100644 --- a/src/Angular.js +++ b/src/Angular.js @@ -1,23 +1,42 @@ //////////////////////////////////// -if (typeof document.getAttribute == 'undefined') +if (typeof document.getAttribute == $undefined) document.getAttribute = function() {}; -var consoleNode, +var _undefined = undefined, + _null = null, + $$element = '$element', + $angular = 'angular', + $array = 'array', + $boolean = 'boolean', + $console = 'console', + $date = 'date', + $display = 'display', + $element = 'element', + $function = 'function', + $length = 'length', + $name = 'name', + $none = 'none', + $noop = 'noop', + $null = 'null', + $number = 'number', + $object = 'object', + $string = 'string', + $undefined = 'undefined', + NG_EXCEPTION = 'ng-exception', + NG_VALIDATION_ERROR = 'ng-validation-error', + NOOP = 'noop', PRIORITY_FIRST = -99999, PRIORITY_WATCH = -1000, PRIORITY_LAST = 99999, PRIORITY = {'FIRST': PRIORITY_FIRST, 'LAST': PRIORITY_LAST, 'WATCH':PRIORITY_WATCH}, - NOOP = 'noop', - NG_EXCEPTION = 'ng-exception', - NG_VALIDATION_ERROR = 'ng-validation-error', jQuery = window['jQuery'] || window['$'], // weirdness to make IE happy _ = window['_'], msie = !!/(msie) ([\w.]+)/.exec(lowercase(navigator.userAgent)), jqLite = jQuery || jqLiteWrap, slice = Array.prototype.slice, - error = window['console'] ? bind(window['console'], window['console']['error'] || noop) : noop, - angular = window['angular'] || (window['angular'] = {}), + error = window[$console] ? bind(window[$console], window[$console]['error'] || noop) : noop, + angular = window[$angular] || (window[$angular] = {}), angularTextMarkup = extensionMap(angular, 'markup'), angularAttrMarkup = extensionMap(angular, 'attrMarkup'), angularDirective = extensionMap(angular, 'directive'), @@ -34,7 +53,7 @@ function foreach(obj, iterator, context) { if (obj) { if (isFunction(obj)){ for (key in obj) { - if (key != 'prototype' && key != 'length' && key != 'name' && obj.hasOwnProperty(key)) { + if (key != 'prototype' && key != $length && key != $name && obj.hasOwnProperty(key)) { iterator.call(context, obj[key], key); } } @@ -75,7 +94,7 @@ function extend(dst) { function inherit(parent, extra) { return extend(new (extend(function(){}, {prototype:parent}))(), extra); -}; +} function noop() {} function identity($) {return $;} @@ -91,7 +110,7 @@ function extensionMap(angular, name, transform) { } function jqLiteWrap(element) { - // for some reasons the parentNode of an orphan looks like null but its typeof is object. + // for some reasons the parentNode of an orphan looks like _null but its typeof is object. if (element) { if (isString(element)) { var div = document.createElement('div'); @@ -103,13 +122,13 @@ function jqLiteWrap(element) { } return element; } -function isUndefined(value){ return typeof value == 'undefined'; } -function isDefined(value){ return typeof value != 'undefined'; } -function isObject(value){ return typeof value == 'object';} +function isUndefined(value){ return typeof value == $undefined; } +function isDefined(value){ return typeof value != $undefined; } +function isObject(value){ return value!=_null && typeof value == 'object';} function isString(value){ return typeof value == 'string';} function isNumber(value){ return typeof value == 'number';} function isArray(value) { return value instanceof Array; } -function isFunction(value){ return typeof value == 'function';} +function isFunction(value){ return typeof value == $function;} function isTextNode(node) { return nodeName(node) == '#text'; } function lowercase(value){ return isString(value) ? value.toLowerCase() : value; } function uppercase(value){ return isString(value) ? value.toUpperCase() : value; } @@ -293,7 +312,7 @@ function escapeAttr(html) { function bind(self, fn) { var curryArgs = arguments.length > 2 ? slice.call(arguments, 2, arguments.length) : []; - if (typeof fn == 'function') { + if (typeof fn == $function) { return curryArgs.length ? function() { return arguments.length ? fn.apply(self, curryArgs.concat(slice.call(arguments, 0, arguments.length))) : fn.apply(self, curryArgs); }: function() { @@ -319,7 +338,7 @@ function merge(src, dst) { for ( var key in src) { var value = dst[key]; var type = typeof value; - if (type == 'undefined') { + if (type == $undefined) { dst[key] = fromJson(toJson(src[key])); } else if (type == 'object' && value.constructor != array && key.substring(0, 1) != "$") { @@ -331,7 +350,6 @@ function merge(src, dst) { function compile(element, existingScope) { var compiler = new Compiler(angularTextMarkup, angularAttrMarkup, angularDirective, angularWidget), $element = jqLite(element); - parent.$element = $element; return compiler.compile($element)($element, existingScope); } ///////////////////////////////////////////////// @@ -359,7 +377,7 @@ function toKeyValue(obj) { function angularInit(config){ if (config.autobind) { // TODO default to the source of angular.js - var scope = compile(window.document, null, {'$config':config}); + var scope = compile(window.document, _null, {'$config':config}); if (config.css) scope.$browser.addCss(config.base_url + config.css); scope.$init(); |
