diff options
Diffstat (limited to 'src/Angular.js')
| -rw-r--r-- | src/Angular.js | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/Angular.js b/src/Angular.js index 17ede3aa..4a0589c3 100644 --- a/src/Angular.js +++ b/src/Angular.js @@ -627,6 +627,22 @@ function copy(source, destination){ } /** + * Create a shallow copy of an object + * @param src + */ +function shallowCopy(src) { + var dst = {}, + key; + for(key in src) { + if (src.hasOwnProperty(key)) { + dst[key] = src[key]; + } + } + return dst; +} + + +/** * @ngdoc function * @name angular.equals * @function @@ -750,6 +766,19 @@ function toBoolean(value) { return value; } +/** + * @returns {string} Returns the string representation of the element. + */ +function startingTag(element) { + element = jqLite(element).clone(); + try { + // 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) {}; + return jqLite('<div>').append(element).html().replace(/\<\/[\w\:\-]+\>$/, ''); +} + ///////////////////////////////////////////////// @@ -918,6 +947,14 @@ function bootstrap(element, modules) { return injector; } +var SNAKE_CASE_REGEXP = /[A-Z]/g; +function snake_case(name, separator){ + separator = separator || '_'; + return name.replace(SNAKE_CASE_REGEXP, function(letter, pos) { + return (pos ? separator : '') + letter.toLowerCase(); + }); +} + function bindJQuery() { // bind to jQuery if present; jQuery = window.jQuery; @@ -951,6 +988,7 @@ function assertArg(arg, name, reason) { } function assertArgFn(arg, name) { + assertArg(arg, name); assertArg(isFunction(arg), name, 'not a function, got ' + (typeof arg == 'object' ? arg.constructor.name || 'Object' : typeof arg)); return arg; |
