From 52ee1ab5eb0f3197453b26c60a70239ac3fffea7 Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Tue, 10 Apr 2012 14:29:49 -0700 Subject: chore(*): remove dead code and fix code style issues --- src/Angular.js | 76 +++++++++------------------------------- src/AngularPublic.js | 2 +- src/angular-bootstrap.js | 3 +- src/jqLite.js | 20 +---------- src/ng/browser.js | 2 +- src/ng/compiler.js | 2 +- src/ng/directive/booleanAttrs.js | 4 +-- src/ng/directive/directives.js | 2 +- src/ng/directive/form.js | 2 +- src/ng/directive/input.js | 6 ++-- src/ng/directive/ngInclude.js | 2 +- src/ng/directive/select.js | 2 +- src/ng/filter/filters.js | 4 +-- src/ng/httpBackend.js | 4 +-- src/ng/location.js | 2 +- src/ng/parse.js | 24 ++----------- src/ng/rootScope.js | 2 +- src/ng/sanitize.js | 2 +- src/ngMock/angular-mocks.js | 9 ++--- src/ngScenario/ObjectModel.js | 2 +- src/ngScenario/Scenario.js | 4 +-- src/ngScenario/dsl.js | 2 +- src/ngScenario/output/Html.js | 2 +- 23 files changed, 50 insertions(+), 130 deletions(-) (limited to 'src') diff --git a/src/Angular.js b/src/Angular.js index beaf81d5..86a7fc1c 100644 --- a/src/Angular.js +++ b/src/Angular.js @@ -2,7 +2,7 @@ //////////////////////////////////// -if (typeof document.getAttribute == $undefined) +if (typeof document.getAttribute == 'undefined') document.getAttribute = function() {}; /** @@ -52,14 +52,7 @@ if ('i' !== 'I'.toLowerCase()) { function fromCharCode(code) {return String.fromCharCode(code);} -var $boolean = 'boolean', - $console = 'console', - $length = 'length', - $name = 'name', - $object = 'object', - $string = 'string', - $undefined = 'undefined', - Error = window.Error, +var Error = window.Error, /** holds major version number for IE or NaN for real browsers */ msie = int((/msie (\d+)/.exec(lowercase(navigator.userAgent)) || [])[1]), jqLite, // delay binding since jQuery could be loaded after us. @@ -107,7 +100,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); } } @@ -138,7 +131,7 @@ function sortedKeys(obj) { } function forEachSorted(obj, iterator, context) { - var keys = sortedKeys(obj) + var keys = sortedKeys(obj); for ( var i = 0; i < keys.length; i++) { iterator.call(context, obj[keys[i]], keys[i]); } @@ -269,7 +262,7 @@ function valueFn(value) {return function() {return value;};} * @param {*} value Reference to check. * @returns {boolean} True if `value` is undefined. */ -function isUndefined(value){return typeof value == $undefined;} +function isUndefined(value){return typeof value == 'undefined';} /** @@ -283,7 +276,7 @@ function isUndefined(value){return typeof value == $undefined;} * @param {*} value Reference to check. * @returns {boolean} True if `value` is defined. */ -function isDefined(value){return typeof value != $undefined;} +function isDefined(value){return typeof value != 'undefined';} /** @@ -298,7 +291,7 @@ function isDefined(value){return typeof value != $undefined;} * @param {*} value Reference to check. * @returns {boolean} True if `value` is an `Object` but not `null`. */ -function isObject(value){return value!=null && typeof value == $object;} +function isObject(value){return value != null && typeof value == 'object';} /** @@ -312,7 +305,7 @@ function isObject(value){return value!=null && typeof value == $object;} * @param {*} value Reference to check. * @returns {boolean} True if `value` is a `String`. */ -function isString(value){return typeof value == $string;} +function isString(value){return typeof value == 'string';} /** @@ -397,8 +390,10 @@ function isFile(obj) { } -function isBoolean(value) {return typeof value == $boolean;} -function isTextNode(node) {return nodeName_(node) == '#text';} +function isBoolean(value) { + return typeof value == 'boolean'; +} + function trim(value) { return isString(value) ? value.replace(/^\s*/, '').replace(/\s*$/, '') : value; @@ -433,26 +428,6 @@ function makeMap(str){ } - -/** - * HTML class which is the only class which can be used in ngBind to inline HTML for security - * reasons. - * - * @constructor - * @param html raw (unsafe) html - * @param {string=} option If set to 'usafe', get method will return raw (unsafe/unsanitized) html - */ -function HTML(html, option) { - this.html = html; - this.get = lowercase(option) == 'unsafe' - ? valueFn(html) - : function htmlSanitize() { - var buf = []; - htmlParser(html, htmlSanitizeWriter(buf)); - return buf.join(''); - }; -} - if (msie < 9) { nodeName_ = function(element) { element = element.nodeName ? element : element[0]; @@ -465,12 +440,6 @@ if (msie < 9) { }; } -function isVisible(element) { - var rect = element[0].getBoundingClientRect(), - width = (rect.width || (rect.right||0 - rect.left||0)), - height = (rect.height || (rect.bottom||0 - rect.top||0)); - return width>0 && height>0; -} function map(obj, iterator, context) { var results = []; @@ -671,17 +640,6 @@ function equals(o1, o2) { return false; } -function setHtml(node, html) { - if (isLeafNode(node)) { - if (msie) { - node.innerText = html; - } else { - node.textContent = html; - } - } else { - node.innerHTML = html; - } -} function concat(array1, array2, index) { return array1.concat(slice.call(array2, index)); @@ -742,7 +700,7 @@ function toJsonReplacer(key, value) { } return val; -}; +} /** @@ -799,7 +757,7 @@ function startingTag(element) { // turns out IE does not let you set .html() on elements which // are not allowed to have children. So we just ignore it. element.html(''); - } catch(e) {}; + } catch(e) {} return jqLite('
').append(element).html().match(/^(<[^>]+>)/)[1]; } @@ -918,7 +876,7 @@ function angularInit(element, bootstrap) { forEach(element.querySelectorAll('.' + name), append); forEach(element.querySelectorAll('.' + name + '\\:'), append); forEach(element.querySelectorAll('[' + name + ']'), append); - }; + } }); forEach(elements, function(element) { @@ -1005,9 +963,7 @@ function bindJQuery() { */ function assertArg(arg, name, reason) { if (!arg) { - var error = new Error("Argument '" + (name||'?') + "' is " + - (reason || "required")); - throw error; + throw new Error("Argument '" + (name || '?') + "' is " + (reason || "required")); } return arg; } diff --git a/src/AngularPublic.js b/src/AngularPublic.js index 1326bf8c..352e14a8 100644 --- a/src/AngularPublic.js +++ b/src/AngularPublic.js @@ -130,4 +130,4 @@ function publishExternalAPI(angular){ }); } ]); -}; +} diff --git a/src/angular-bootstrap.js b/src/angular-bootstrap.js index 5b6e5937..716731a5 100644 --- a/src/angular-bootstrap.js +++ b/src/angular-bootstrap.js @@ -9,7 +9,6 @@ var filename = /^(.*\/)angular-bootstrap.js(#.*)?$/, scripts = document.getElementsByTagName("SCRIPT"), - config, serverPath, match, globalVars = {}; @@ -84,7 +83,7 @@ document.write(''); } - } + }; function addCss(file) { document.write('\s]+))?)*)\s*(\/?)\s*>/, diff --git a/src/ngMock/angular-mocks.js b/src/ngMock/angular-mocks.js index 42d921e3..4478f389 100644 --- a/src/ngMock/angular-mocks.js +++ b/src/ngMock/angular-mocks.js @@ -241,13 +241,15 @@ angular.mock.$ExceptionHandlerProvider = function() { break; case 'log': var errors = []; + handler = function(e) { if (arguments.length == 1) { errors.push(e); } else { errors.push([].slice.call(arguments, 0)); } - } + }; + handler.errors = errors; break; default: @@ -445,7 +447,7 @@ angular.mock.$LogProvider = function() { if (angular.isString(timestamp)) { var tsStr = timestamp; - self.origDate = jsonStringToDate(timestamp) + self.origDate = jsonStringToDate(timestamp); timestamp = self.origDate.getTime(); if (isNaN(timestamp)) @@ -1224,7 +1226,7 @@ function createHttpBackendMock($delegate, $browser) { } }); } -}; +} function MockHttpExpectation(method, url, data, headers) { @@ -1544,7 +1546,6 @@ window.jasmine && (function(window) { */ window.module = angular.mock.module = function() { var moduleFns = Array.prototype.slice.call(arguments, 0); - var stack = new Error('Module Declaration Location:').stack; return isSpecRunning() ? workFn() : workFn; ///////////////////// function workFn() { diff --git a/src/ngScenario/ObjectModel.js b/src/ngScenario/ObjectModel.js index b4dad1a5..609652f4 100644 --- a/src/ngScenario/ObjectModel.js +++ b/src/ngScenario/ObjectModel.js @@ -73,7 +73,7 @@ angular.scenario.ObjectModel = function(runner) { self.emit('StepBegin', it, step); }); - runner.on('StepEnd', function(spec, step) { + runner.on('StepEnd', function(spec) { var it = self.getSpec(spec.id); var step = it.getLastStep(); if (step.name !== step.name) diff --git a/src/ngScenario/Scenario.js b/src/ngScenario/Scenario.js index 7335d5de..19da6444 100644 --- a/src/ngScenario/Scenario.js +++ b/src/ngScenario/Scenario.js @@ -176,7 +176,7 @@ function asyncForEach(list, iterator, done) { * to a specific line length. * * @param {Object} error The exception to format, can be anything throwable - * @param {Number} maxStackLines Optional. max lines of the stack trace to include + * @param {Number=} [maxStackLines=5] max lines of the stack trace to include * default is 5. */ function formatException(error, maxStackLines) { @@ -307,7 +307,7 @@ function browserTrigger(element, type, keys) { pressed('shift'), pressed('meta'), 0, element); element.dispatchEvent(evnt); - finalProcessDefault = !(appWindow.angular['ff-684208-preventDefault'] || !fakeProcessDefault) + finalProcessDefault = !(appWindow.angular['ff-684208-preventDefault'] || !fakeProcessDefault); delete appWindow.angular['ff-684208-preventDefault']; diff --git a/src/ngScenario/dsl.js b/src/ngScenario/dsl.js index 7f399394..7ca33a26 100644 --- a/src/ngScenario/dsl.js +++ b/src/ngScenario/dsl.js @@ -128,7 +128,7 @@ angular.scenario.dsl('browser', function() { return api; }; - return function(time) { + return function() { return chain; }; }); diff --git a/src/ngScenario/output/Html.js b/src/ngScenario/output/Html.js index 326928d8..7f69a734 100644 --- a/src/ngScenario/output/Html.js +++ b/src/ngScenario/output/Html.js @@ -24,7 +24,7 @@ angular.scenario.output('html', function(context, runner, model) { '
' ); - runner.on('InteractivePause', function(spec, step) { + runner.on('InteractivePause', function(spec) { var ui = lastStepUiMap[spec.id]; ui.find('.test-title'). html('paused... resume when ready.'); -- cgit v1.2.3