Commit graph

348 commits

Author SHA1 Message Date
Karl Seamon
cb29632a58 perf: use faster check for $$ prefix
Use two calls to charAt instead of substr to detect a $$prefix in the shallowCopy functions.
This makes shallowCopy 25-50% faster (depending on which browser is used).
http://jsperf.com/angular-shallow-copy

Closes #5457
2013-12-17 11:43:57 -08:00
Michał Gołębiowski
3410f65e79 perf(jqLite): implement and use the empty method in place of html(‘’)
jQuery's elem.html('') is way slower than elem.empty(). As clearing
element contents happens quite often in certain scenarios, switching
to using .empty() provides a significant performance boost when using
Angular with jQuery.

Closes #4457
2013-12-13 02:07:11 -08:00
Karl Seamon
62dbe85798 perf: use call and === instead of apply and == in type check functions
Updates isDate et al to use call instead of apply and === instead of ==.
The change to call brings minor performance improvement and === is just
better practice than ==.
http://jsperf.com/call-vs-apply-tostring

Closes #5295
2013-12-13 00:22:47 -08:00
Matias Niemelä
dbf8c3c745 revert: chore(Angular.js): Use call and === instead of apply and == in type check functions 2013-12-06 13:14:08 -05:00
Tobias Bosch
b0972a2e75 fix($compile): update cloned elements if the template arrives after the cloning
If an element has a directive whose content is loaded using `templateUrl`,
and the element is cloned using a linking function before the template arrives,
the clone needs to be updated as well.

This also updates `ngIf` and `ngRepeat` to keep the connection to the clone
of a tranclude function, so that they know about the changes a directive with
`templateUrl` does to the element in the future.

Fixes to #4930.
2013-12-05 22:16:25 -08:00
Caitlin Potter
2dbb6f9a54 fix(isElement): return boolean value rather than truthy value.
angular.isElement currently returns a truthy object/function, or false. This
patch aims to correct this behaviour by casting the result of the isElement
expression to a boolean value via double-negation.

Closes #4519
Closes #4534
2013-12-05 17:14:05 -08:00
Karl Seamon
785a5fd7c1 chore(Angular.js): Use call and === instead of apply and == in type check functions
Updates isDate et al to use call instead of apply and === instead of ==.
The change to call brings minor performance improvement and === is just
better practice than ==.
http://jsperf.com/call-vs-apply-tostring

Closes #5295
2013-12-05 16:43:11 -08:00
Igor Minar
bb36bc7edf style(Angular.js): fix typo in comment 2013-12-03 15:44:13 -08:00
sunnylost
c2e45c769e refactor(angular.js): improve trim performance
According to Flagrant Badassery's blog
http://blog.stevenlevithan.com/archives/faster-trim-javascript
and this comparison http://jsperf.com/trim-function, this trim method is faster.

Closes #4406
2013-11-26 06:45:47 +00:00
Matias Niemelä
0cd7e8f227 fix($compile): ensure CSS classes are added and removed only when necessary
When $compile interpolates a CSS class attribute expression it will
do so by comparing the CSS class value already present on the element.
This may lead to unexpected results when dealing with ngClass values being
added and removed therefore it is best that both compile and ngClass delegate
addClass/removeClass operations to the same block of code.
2013-11-21 20:47:44 -05:00
Matias Niemelä
6b8bbe4d90 fix(ngClass): ensure that ngClass only adds/removes the changed classes
ngClass works by removing all the former classes and then adding all the
new classes to the element during each watch change operation. This may
cause transition animations to never render. The ngClass directive will
now only add and remove the classes that change during each watch operation.

Closes #4960
Closes #4944
2013-11-20 17:15:56 -05:00
Pete Bacon Darwin
29274e1d8d docs(ngApp): improve description and example 2013-11-18 16:21:59 +00:00
Igor Minar
98adc9e038 fix($animate): don't force animations to be enabled
The way that enabling of animations was set up, made it impossible to inject a
module into the bootstrap to disable animations for things like end 2 end tests.
Now animations are temporarily blocked by setting the animation state to RUNNING
during bootstrap, which allows the developer to permanently disable at any point
by calling $animate.enabled(false).
2013-11-08 01:03:17 -08:00
Igor Minar
27e9340b3c feat(jqLite): expose isolateScope() getter similar to scope()
See doc update in the diff for more info.

BREAKING CHANGE: jqLite#scope() does not return the isolate scope on the element
that triggered directive with isolate scope. Use jqLite#isolateScope() instead.
2013-11-07 22:08:22 -08:00
Tobias Bosch
3662140201 docs(guide/filter): Refactor filter guide docs
This refactors the filter guide docs into a single file.
Also removes out of date references to the fact that Angular used to enhance Arrays while evaluating expressions.
2013-11-07 14:14:57 -08:00
Brian Ford
6578bd0c82 chore: move getBlockElements to Angular.js 2013-10-30 16:21:02 -07:00
thorn0
9f0d4085e7 docs(Angular.js): angular.equals calls itself recursively on objects
Closes #4622
2013-10-26 18:57:59 +01:00
Vojta Jina
f2fab49830 style: make jshint happy 2013-10-22 15:32:41 -07:00
Igor Minar
08f376f2ea fix(csp): fix csp auto-detection and stylesheet injection
When we refactored , we broke the csp mode because the previous implementation
relied on the fact that it was ok to lazy initialize the .csp property, this
is not the case any more.

Besides, we need to know about csp mode during bootstrap and avoid injecting the
stylesheet when csp is active, so I refactored the code to fix both issues.

PR #4411 will follow up on this commit and add more improvements.

Closes #917
Closes #2963
Closes #4394
Closes #4444

BREAKING CHANGE: triggering ngCsp directive via `ng:csp` attribute is not
supported any more. Please use data-ng-csp instead.
2013-10-18 17:33:53 -07:00
Marc Tamlyn
bed08c9c66 docs(angular.equals): fix simple typo
- JavasScript -> Javascript

Closes #4323
2013-10-08 12:32:20 +01:00
Peter Bacon Darwin
7a586e5c19 fix(*): protect calls to hasOwnProperty in public API
Objects received from outside AngularJS may have had their `hasOwnProperty`
method overridden with something else. In cases where we can do this without
incurring a performance penalty we call directly on Object.prototype.hasOwnProperty
to ensure that we use the correct method.

Also, we have some internal hash objects, where the keys for the map are provided
from outside AngularJS. In such cases we either prevent `hasOwnProperty` from
being used as a key or provide some other way of preventing our objects from
having their `hasOwnProperty` overridden.

BREAKING CHANGE: Inputs with name equal to "hasOwnProperty" are not allowed inside
form or ngForm directives.

Before, inputs whose name was "hasOwnProperty" were quietly ignored and not added
to the scope.  Now a badname exception is thrown.

Using "hasOwnProperty" for an input name would be very unusual and bad practice.
Either do not include such an input in a `form` or `ngForm` directive or change
the name of the input.

Closes #3331
2013-10-07 09:01:13 -07:00
Joe Hanink
1691c4e9a3 docs(angular.bind): clarify that bind is partial application
The `angular.bind` function reflects the definition of "partial application", which
reduces a function's arity rather than transforming a function with n args into a
chain of n functions, each having a single arg.

curry : f(x,y,z) -> f(x)(y)(z)
partial application : f(x,y,z) -> f(x)(y,z)

Closes #4239
2013-10-03 23:37:09 +01:00
Daniel Luz
5b8c78843e fix(isArrayLike): correctly handle string primitives
Closes #3356
2013-10-02 16:57:26 -07:00
Uri Goldshtein
fc05f5e701 docs(angular.copy): add an example with the two possible arguments
Closes #4179
2013-09-30 22:15:57 +01:00
Boris Serdyuk
6c59e77008 refactor(angular.toJson): use charAt instead of regexp
Provides a performance improvement when serializing to JSON strings.

Closes #4093
2013-09-23 11:16:16 +01:00
Dave Peticolas
2468974a53 doc(ngApp): fix grammar 2013-09-19 20:17:26 +01:00
jakub-bochenski
ce351e69b1 docs(angular.copy): clarify corner cases
The behaviour when null or undefined was passed was not clear.
The exception thrown when source == destination was not documented.

Closes #3946
2013-09-10 22:03:08 +01:00
Pete Bacon Darwin
327a78604a docs(angular.bootstrap): clarify modules parameter
It was not clear what you could pass to specify modules to load in the
`module` parameter of this function. The `modules` parameter takes an
array.

The main case is to provide a String, which is the name of a "predefined"
angular module.
The side cases are to provide a Function (or an annotated function in the
form of an Array), which will be invoked by the injector as a run block.

It is not possible to "define" new modules via this parameter.

Closes #3692
2013-09-05 12:18:56 +01:00
Chirayu Krishnappa
427ee93f11 fix(core): parse IE11 UA string correctly
It's great that IE11 wants to be compatible enough that it doesn't want
to be special cased and treated differently.

However, as long as one has to have a different code path for IE than
for the other supported browsers, we still need to detect and special
case it.  For instance, our URL parsing code still needs the same
workaround the we used for IE10.  We still see the same Access denied /
TypeError exceptions when setting certain values.  FYI, Angular doesn't
generally blindly test for IE – we also check the version number.

Thanks to modern.ie for the free IE11 test VM.

Closes #3682
2013-08-29 16:07:49 -07:00
Jeff Cross
3ee744cc63 fix(re-bootstrap): Throw an error when bootstrapping a bootstrapped element.
Nothing would prevent a user from accidentally calling angular.bootstrap on an element that had already been bootstrapped. If this was done, odd behavior could manifest in an application, causing different scopes to update the same DOM, and causing debugger confusion.

This fix adds a check inside of angular.bootstrap to check if the passed-in element already has an injector, and if so, will throw an error.
2013-08-09 13:14:12 -07:00
Andy Hitchman
f80730f497 fix(angular.copy): change angular.copy to correcly clone RegExp
angular.copy previously copied RegExp as an empty object. Change detects
RegExp instance and clones into new RegExp. This change is based on a previous
fix to allow Date to be copied.

Closes #3473
Closes #3474
2013-08-08 23:29:59 -07:00
Daniel Herman
fad626f304 fix(isArrayLike) Correctly detect arrayLike items
Change the implementation of isArrayLike to use one heavily based on the
implementation in jQuery in order to correctly detect array-like
objects, that way functionality like ngRepeat works as expected.
2013-07-31 11:08:56 -07:00
Carl Danley
258e986284 docs(*): fixed typos and ngdoc parameter names 2013-07-27 20:53:41 +02:00
Matias Niemelä
81923f1e41 feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
  - $animate.enter(element, parent, after, done);
  - $animate.leave(element, done);
  - $animate.move(element, parent, after, done);
  - $animate.addClass(element, className, done);
  - $animate.removeClass(element, className, done);

BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-07-26 23:49:54 -07:00
Brenton
1dcafd18af fix(equals): {} and [] should not be considered equivalent
angular.equals was returning inconsistent values for the comparison between
{} and []:

    angular.equals({}, []) // true
    angular.equals([], {}]) // false

Since these object are not of the same type, they should not be considered
equivalent.
2013-07-24 10:58:56 -07:00
Braden Shepherdson
dfa83475a5 docs(bootstrap): Note that ngScenario requires ngApp
ngScenario expects an ngApp directive to be used, and doesn't work for
manually bootstrapped apps. The failure mode is to hang on navigation.

Trying to make this wont-fix bug less obscure by documenting it.
Eventually Protractor will replace ngScenario and fix this.
2013-07-23 20:33:01 +01:00
Ben Ripkens
724819e3cf fix(angular.equals): add support for regular expressions
Regular expression objects didn't used to be considered to be equal when using
'angular.equals'. Dirty checking therefore failed to recognize a
property modification.

Closes #2685
2013-07-13 22:22:28 -07:00
Greg Thornton
5a294c8646 feat(Angular.js): skip JSON.stringify for undefined
Return early in `angular.toJson` if the object to be stringified is `undefined`.
IE8 stringifies `undefined` to `'undefined'` whereas other browsers return
`undefined`. This normalizes behavior and passes currently broken unit tests
in IE8.
2013-07-12 20:32:40 +02:00
Eric Subach
a83ed0e6c3 refactor(Angular.js): remove code duplication
Closes #2890
2013-07-11 22:01:29 +02:00
Marco Vito Moscaritolo
f89ba38dcd docs(angular.identity): fix missing 'angular' in identity function 2013-07-09 14:31:21 +01:00
Daniel Luz
7829c50f9e fix(angular.equals): do not match keys defined in the prototype chain
Merely testing for object[key] will give incorrect results on keys
defined in Object.prototype.
Note: IE8 is generally broken in this regard since `for...in` never returns
certain property keys even if they are defined directly on the object.

See #2141 - partially merges this PR
2013-07-08 11:05:08 +01:00
Sebastian Müller
22b9b47576 refactor(core): use native String.prototype.trim if available 2013-07-03 01:42:41 -07:00
joshkurz
807394095b fix(Angular.js): handle duplicate params in parseKeyValue/toKeyValue
parseKeyValue and toKeyValue can now handle duplicate values in the query.
```
?x=1&x=2 <-> {x:[1,2]}
```

The algorithm looks like:
    1)parseKeyValue looks for presence of obj[key]
    2)detects and replaces obj[key] with [obj[key],val]
    3)then pushes more duplicates if necessary
    4)toKeyValue decodes array correctly
    5)(not changed)$location.search({param: 'key'}) still replaces if necessary
    6)(not changed)$location.search({param: ['key1', 'key2']}) sets the url with duplicates

BREAKING CHANGE: Before this change:
- `parseKeyValue` only took the last key overwriting all the previous keys;
- `toKeyValue` joined the keys together in a comma delimited string.
This was deemed buggy behavior. If your server relied on this behavior
then either the server should be fixed or a simple serialization of
the array should be done on the client before passing it to $location.
2013-07-01 19:32:12 +01:00
Spencer Applegate
1532ec1dfe docs(Angular.js): explain that toJson strips $... properties
In Angular.toJson, any properties with a leading '$' character will be
stripped from the resulting string since angular uses this notation
internally for services.  There have been complaints of not knowing
about this functionality until it breaks within their code.
2013-07-01 11:35:16 +01:00
Chirayu Krishnappa
cefdaf131d fix($parse): move global getter out of parse.js 2013-06-24 20:46:32 -07:00
Pete Bacon Darwin
097947fd3b refactor(angular.bootstrap): rename internal function 2013-06-20 15:22:35 +01:00
Pete Bacon Darwin
8264d08085 fix(Angular.js): don't crash on invalid query parameters 2013-06-20 14:13:16 +01:00
Michał Gołębiowski
f1b94b4b59 feat(jqLite): switch bind/unbind to more recent jQuery on/off
jQuery switched to a completely new event binding implementation as of
1.7.0, centering around on/off methods instead of previous bind/unbind.
This patch makes jqLite match this implementation while still supporting
previous bind/unbind methods.
2013-06-19 20:53:24 +01:00
Ken Sheedlo
003861d2fd chore(minErr): replace ngError with minErr 2013-06-17 13:29:30 -07:00
Matias Niemelä
9faabd1ba0 chore(AngularPublic): remove angular.noConflict feature 2013-06-06 22:06:50 -07:00