Commit graph

1410 commits

Author SHA1 Message Date
Igor Minar
faf5b980da fix($compile): instantiate controlers when re-entering compilation
When we re-enter compilation either due to async directive templates or element transclude directive
we need to keep track of controllers to instantiate during linking.

This piece of info was missing when re-entering compilation and that's what this commit fixes.

I also reordered the properties in the previousCompileContext object.

Closes #4434
Closes #4616
2013-10-24 13:54:15 -07:00
Dmitry Shirokov
4b653aeac1 fix(input): keep track of min/max attars on-the-fly
Now input[type=button] keeps track of both min and max attrs even if they change over time.
2013-10-24 09:19:55 -04:00
Matias Niemelä
3f568b22f9 fix(ngView): ensure the new view element is placed after the old view element
Closes #4362
2013-10-23 10:30:45 -07:00
Matias Niemelä
2623de1426 fix($animate): ensure animations work properly when the $rootElement is being animated
Closes #4397
Closes #4231
2013-10-23 07:26:41 -04:00
Matias Niemelä
f5289fe84f fix($animate): only cancel class-based animations if the follow-up class contains CSS transition/keyframe animation code
Closes #4463
Closes #3784
2013-10-23 07:08:03 -04: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
Vojta Jina
c22adbf160 fix($injector): allow a constructor function to return a function
This change makes `$injector.instantiate` (and thus `$provide.service`) to behave the same as native
`new` operator.
2013-10-18 15:26:51 -07:00
Chirayu Krishnappa
6d324c76f0 fix($parse): check function call context to be safe
Closes #4417
2013-10-15 06:43:19 -07:00
Igor Minar
63c5334c84 fix($compile): abort compilation when duplicate element transclusion
Issue an error and abort compilation when two directives that ask for transclusion are found
on a single element. This configuration is not supported and we previously failed to issue
the error because in the case of element transclusion the compilation is re-started and this
caused the compilation context to be lost.

The ngRepeat directive has been special-cased to bypass this warning because it knows how to
handle this scenario internally.

This is not an ideal solution to the problem of multiple transclusions per element, we are
hoping to have this configuration supported by the compiler in the future. See #4357.

Closes #3893
Closes #4217
Closes #3307
2013-10-11 17:12:24 -07:00
Matias Niemelä
b1e604e38c fix($animate): perform internal caching on getComputedStyle to boost the performance of CSS3 transitions/animations
Closes #4011
Closes #4124
2013-10-10 17:35:36 -07:00
Matias Niemelä
cc5846073e fix($animate): ensure structural animations skip all child animations even if no animation is present during compile
Closes #3215
2013-10-10 17:35:36 -07:00
Matias Niemelä
23c698821f refactor($animate): queue all successive animations to use only one reflow 2013-10-10 17:35:36 -07:00
Matias Niemelä
3f31a7c769 fix($animate): cancel any ongoing child animations during move and leave animations 2013-10-10 17:35:36 -07:00
Matias Niemelä
079dd93991 fix($animate): ensure elapsedTime always considers delay values 2013-10-10 17:35:36 -07:00
Pete Bacon Darwin
07272608d8 fix(modules): stop leaking global variables in tests
The routeUtils.js file was declaring a number of functions that were
leaking into other modules such as ngMocks causing tests to pass
incorrectly.

Closes #4360
2013-10-10 11:58:15 -07:00
Jeff Cross
b019a48bb1 refactor(location): $location now uses urlUtils, not RegEx
The location service, and other portions of the application,
were relying on a complicated regular expression to get parts of a URL.
But there is already a private urlUtils provider,
which relies on HTMLAnchorElement to provide this information,
and is suitable for most cases.

In order to make urlUtils more accessible in the absence of DI,
its methods were converted to standalone functions available globally.

The urlUtils.resolve method was renamed urlResolve,
and was refactored to only take 1 argument, url,
and not the 2nd "parse" boolean.
The method now always returns a parsed url.
All places in code which previously wanted a string instead of a parsed
url can now get the value from the href property of the returned object.

Tests were also added to ensure IPv6 addresses were handled correctly.

Closes #3533
Closes #2950
Closes #3249
2013-10-10 11:41:07 -07:00
jankuca
9efa46ae64 feat(ngRepeat): use block separator comments
Issue: multi-elements ng-repeat (ng-repeat-start, ng-repeat-end) can contain elements with a trancluding directive. This directive changes content of the row (template) and ng-repeat does not work correctly (when removing/moving rows), because ng-repeat works with the original template (elements).

This changes ng-repeat behavior to traverse the DOM to find current elements everytime we are moving/removing rows (if the template has multiple elements).

Closes #3104
2013-10-09 15:19:10 -07:00
Vojta Jina
64fd2c421e fix(jqLite): ignore class methods on comment elements
Since c785267e jqLite uses setAttribute (rather than className property) in order to change classes. Some elements (eg. Comment) do not have this method which blows up.

jQuery silently ignores these method calls (because it uses className), so to get the same behavior as jQuery, we check for setAttribute method first.
2013-10-09 15:19:10 -07:00
Igor Minar
b6a37d112b revert: fix($parse): handle promises returned from parsed function calls
This reverts commit 3a65822023.

The change cased regressions in third party components that require
promises from getter functions not to be unwrapped.

Since we have deprecated the promise unwrapping support in $parse it
doesn't make much sense to fix this issue and deal with regressions in
third party code.

Closes #4158
2013-10-09 15:15:43 -07:00
Igor Minar
5dc35b527b fix($parse): deprecate promise unwrapping and make it an opt-in
This commit disables promise unwrapping and adds
$parseProvider.unwrapPromises() getter/setter api that allows developers
to turn the feature back on if needed. Promise unwrapping support will
be removed from Angular in the future and this setting only allows for
enabling it during transitional period.

If the unwrapping is enabled, Angular will log a warning about each
expression that unwraps a promise (to reduce the noise, each expression
is logged only onces). To disable this logging use
`$parseProvider.logPromiseWarnings(false)`.

Previously promises found anywhere in the expression during expression
evaluation would evaluate to undefined while unresolved and to the
fulfillment value if fulfilled.

This is a feature that didn't prove to be wildly useful or popular,
primarily because of the dichotomy between data access in templates
(accessed as raw values) and controller code (accessed as promises).

In most code we ended up resolving promises manually in controllers
or automatically via routing and unifying the model access in this way.

Other downsides of automatic promise unwrapping:

- when building components it's often desirable to receive the
  raw promises
- adds complexity and slows down expression evaluation
- makes expression code pre-generation unattractive due to the
  amount of code that needs to be generated
- makes IDE auto-completion and tool support hard
- adds too much magic

BREAKING CHANGE: $parse and templates in general will no longer
automatically unwrap promises. This feature has been deprecated and
if absolutely needed, it can be reenabled during transitional period
via `$parseProvider.unwrapPromises(true)` api.

Closes #4158
Closes #4270
2013-10-09 15:15:43 -07:00
Brian Ford
1366556ace test(filters): fix timezone-dependent test
Closes #4218
2013-10-09 10:18:51 -07:00
Steven Sojka
9fd92cc3c9 fix(ngTouch): ngClick does not pass touchend event when jQuery is loaded
The trigger handler event in jqLite takes an event object as a second
parameter, but jQuery requires an array of parameters. This is causing
the touchend event to not come thtough in the click handler when jQuery
is loaded.
2013-10-08 09:14:33 -07:00
Adam Kent
507d8021b1 fix(ngTouch): add $event to ng-swipe
Existing documentation implies that an Event object should be available
as `$event` on swipe directives, which previously was only working for
`ng-click`.

Closes #4071
Closes #4321
2013-10-08 12:55:16 +01:00
Pete Bacon Darwin
b56b21a898 fix(input): false is no longer an empty value by default
`checkboxInputType` and `ngList` directives need to have special logic for whether
they are empty or not.  Previously this had been hard coded into their
own directives or the `ngRequired` directive.  This made it difficult to handle
these special cases.

This change factors out the question of whether an input is empty into a method
`$isEmpty` on the `ngModelController`.  The `ngRequired` directive now uses this
method when testing for validity and directives, such as `checkbox` or `ngList`
can override it to apply logic specific to their needs.

Closes #3490, #3658, #2594
2013-10-07 16:47:51 -07:00
Julie
2b5ce84fca feat($interval): add a service wrapping setInterval
The $interval service simplifies creating and testing recurring tasks.
This service does not increment $browser's outstanding request count,
which means that scenario tests and Protractor tests will not timeout
when a site uses a polling function registered by $interval. Provides
a workaround for #2402.

For unit tests, repeated tasks can be controlled using ngMock$interval's
tick(), tickNext(), and tickAll() functions.
2013-10-07 13:45:40 -07: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
Peter Bacon Darwin
9af8f4e585 style(injectorSpec): add semicolons & test helpers 2013-10-07 08:45:25 -07:00
Peter Bacon Darwin
d3fce9e82c style(angularSpec): add missing semicolon 2013-10-07 08:45:25 -07:00
Pete Bacon Darwin
47f7bd706e fix(rootScope): make stopPropagation only stop its own event
All sibling event handlers residing on the same scope to were stopped
if one of them called stopPropagation.

Closes #4204
2013-10-05 22:45:43 +01:00
Jen Bourey
8336b3a286 fix(ngResource): Remove request body from $delete
Prevent the  obj.$delete instance method from sending the resource as the request body.  This commit uses the existing hasBody boolean to only set httpConfig.data for methods which should have a request body.

Closes #4280
2013-10-04 16:50:08 -07:00
jankuca
49e06eace5 chore($parse): convert parser() and lex() to prototype-based code
This reduces memory consumption of parsed angular expressions and
speeds up parsing.

This JSPerf case demonstrates the performance boost:
http://jsperf.com/closure-vs-prototype-ngparser

Chrome: 1.5–2x boost
FF: slightly slower (I would love to know why)
IE: 4x boost

To be clear, this doesn't have any impact on runtime performance
of expressions as demostrated in this JSPerf:
http://jsperf.com/angular-parser-changes

Closes #3681
2013-10-04 14:15:56 -07:00
Nicola Peduzzi
0ff86c3233 fix(routeProvider): parametrized routes do not match against locations that would not valorize each parameters. 2013-10-04 08:45:47 -07:00
Igor Minar
31f190d4d5 fix($compile): fix (reverse) directive postLink fn execution order
previously the compile/link fns executed in this order controlled via priority:

- CompilePriorityHigh, CompilePriorityMedium, CompilePriorityLow
- PreLinkPriorityHigh, PreLinkPriorityMedium, PreLinkPriorityLow
- link children
- PostLinkPriorityHigh, PostLinkPriorityMedium, PostLinkPriorityLow

This was changed to:

- CompilePriorityHigh, CompilePriorityMedium, CompilePriorityLow
- PreLinkPriorityHigh, PreLinkPriorityMedium, PreLinkPriorityLow
- link children
- PostLinkPriorityLow, PostLinkPriorityMedium , PostLinkPriorityHigh

Using this order the child transclusion directive that gets replaced
onto the current element get executed correctly (see issue #3558),
and more generally, the order of execution of post linking function
makes more sense. The incorrect order was an oversight that has
gone unnoticed for many suns and moons.

(FYI: postLink functions are the default linking functions)

BREAKING CHANGE: the order of postLink fn is now mirror opposite of
the order in which corresponding preLinking and compile functions
execute.

Very few directives in practice rely on order of postLinking function
(unlike on the order of compile functions), so in the rare case
of this change affecting an existing directive, it might be necessary
to convert it to a preLinking function or give it negative priority
(look at the diff of this commit to see how an internal attribute
interpolation directive was adjusted).

Closes #3558
2013-10-03 22:23:37 -07:00
Igor Minar
fe2145016c fix($compile): don't terminate compilation for regular transclusion directives
Previously we would stop the compilation for both regular and element
transclusion directives which was wrong. Only element transclusion directives
should be terminal.
2013-10-03 22:19:46 -07:00
paolo-delmundo
e66c23fe55 fix($sanitize): sanitize DOCTYPE declarations correctly
HTML to be sanitized that contains a DOCTYPE declaration were causing
the HTML parser to throw an error.  Now the parser correctly removes
the declarations when sanitizing HTML.

Closes #3931
2013-10-03 08:42:15 +01:00
jankuca
e36e28ebd4 fix($resource): pass transformed value to both callbacks and promises
Closes #3817
2013-10-02 17:03:53 -07:00
Daniel Luz
5b8c78843e fix(isArrayLike): correctly handle string primitives
Closes #3356
2013-10-02 16:57:26 -07:00
Vojta Jina
fc8034b352 feat(ngMock.$timeout): remove flushNext method 2013-10-02 15:59:49 -07:00
Angel Balcarcel
d70711481e fix($location): prevent infinite digest error in IE7
Refactored `replacedUrl` to store the new URL on both
`location.replace` and setting `location.href` directly to handle
delays in the actual location value change in IE.

Closes #2802
2013-10-02 15:33:31 -07:00
Chirayu Krishnappa
78a5889bc6 test($sce): ie8 fix for entire file
Ref: https://github.com/angular/angular.js/pull/4221#/issuecomment-25515813

Closes #4221
2013-10-02 12:06:27 -07:00
Lucas Galfasó
10cc1a42c9 fix($scope): $evalAsync executes on the right scope
Executes $evalAsync at the scope that the call was made

Closes: #3548
2013-10-02 11:10:29 -07:00
Jamie Mason
8e6e3ebad9 fix($compile): ng-attr to support dash separated attribute names 2013-10-02 10:52:31 -07:00
Pete Bacon Darwin
ac72bee400 style(rootScopeSpec): add semi-colons 2013-10-02 14:15:09 +01:00
Pete Bacon Darwin
2977067726 style($qSpec): add semi-colons 2013-10-02 14:12:35 +01:00
Chirayu Krishnappa
6231a7cf6a test($sce): make ie8 happy
Ref: https://github.com/angular/angular.js/pull/4221#/issuecomment-25515813

Closes #4221
2013-10-01 23:47:01 -07:00
Francesco Pontillo
8e1276c011 fix($compile): allow interpolations for non-event handlers attrs
Fix wrong behaviour that didn't allow 'data-on' and 'on' element attributes
to be interpolated by $compile. The regex now accepts any string beginning
with 'on' and with at least one more English letter.
2013-10-01 15:08:23 -07:00
Ricardo Bin
e9a222418a fix($httpBackend): set headers with falsy values
This is a breaking change. To migrate to the new behavior,
delete or set headers to `undefined` to avoid having them sent.
To restore the old behavior, override `$httpBackendProvider`
with the old implementation.

Closes #2984
2013-10-01 14:02:00 -07:00
Matias Niemelä
2a63dfa6cc fix($animator): avoid completing the animation asynchronously unless CSS transtiions/animations are present
Closes #4023
Closes #3940
2013-10-01 15:00:16 -04:00
James Roper
0d0330adc2 fix($httpBackend): don't send empty string bodies
The `XMLHttpRequest.send` spec defines different semantics for `null`
than for an empty String: an empty String should be sent with a
`Content-Type` of `text/plain`, whereas `null` should have no
`Content-Type` header set.

Closes #2149
2013-10-01 11:28:21 -07:00
jquadrin
0ca5426184 chore: remove Firefox CORS workaround
See #1468
2013-10-01 10:26:08 -07:00