Commit graph

371 commits

Author SHA1 Message Date
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
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
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
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
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
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
Henning Teek
025c921903 fix(dateFilter): allow negative millisecond value strings 2013-10-01 10:18:03 -07:00
Colin Casey
4033cf2814 feat(filter): allow map of filters to be registered
This feature adds similar functionality to what `$ControllerProvider.register`
and `$CompileProvider.directive` currently provide by allowing a map of filter
name/factories to be passed as the sole argument to `$FilterProvider.register`
to register all of the specified filters.

Closes #4036
Closes #4091
2013-10-01 10:26:36 +01:00
Chirayu Krishnappa
93ce5923e9 feat($sce): simpler patterns for $sceDelegateProviders white/blacklists
Closes #4006
2013-10-01 00:41:07 -07:00
jankuca
5a1a6b86a8 fix(ngTransclude): detect ngTranslude usage without a transclusion directive
Closes #3759
2013-09-30 16:44:19 -07:00
Vojta Jina
742271ffa3 fix($compile): link parents before traversing
How did compiling a templateUrl (async) directive with `replace:true` work before this commit?
1/ apply all directives with higher priority than the templateUrl directive
2/ partially apply the templateUrl directive (create `beforeTemplateNodeLinkFn`)
3/ fetch the template
4/ apply second part of the templateUrl directive on the fetched template
(`afterTemplateNodeLinkFn`)

That is, the templateUrl directive is basically split into two parts (two `nodeLinkFn` functions),
which has to be both applied.

Normally we compose linking functions (`nodeLinkFn`) using continuation - calling the linking
function of a parent element, passing the linking function of the child elements as an argument. The
parent linking function then does:
1/ execute its pre-link functions
2/ call the child elements linking function (traverse)
3/ execute its post-link functions

Now, we have two linking functions for the same DOM element level (because the templateUrl directive
has been split).

There has been multiple issues because of the order of these two linking functions (creating
controller before setting up scope locals, running linking functions before instantiating
controller, etc.). It is easy to fix one use case, but it breaks some other use case. It is hard to
decide what is the "correct" order of these two linking functions as they are essentially on the
same level.

Running them side-by-side screws up pre/post linking functions for the high priority directives
(those executed before the templateUrl directive). It runs post-linking functions before traversing:
```js
beforeTemplateNodeLinkFn(null); // do not travers
afterTemplateNodeLinkFn(afterTemplateChildLinkFn);
```

Composing them (in any order) screws up the order of post-linking functions. We could fix this by
having post-linking functions to execute in reverse order (from the lowest priority to the highest)
which might actually make a sense.

**My solution is to remove this splitting.** This commit removes the `beforeTemplateNodeLinkFn`. The
first run (before we have the template) only schedules fetching the template. The rest (creating
scope locals, instantiating a controller, linking functions, etc) is done when processing the
directive again (in the context of the already fetched template; this is the cloned
`derivedSyncDirective`).

We still need to pass-through the linking functions of the higher priority directives (those
executed before the templateUrl directive), that's why I added `preLinkFns` and `postLinkFns`
arguments to `applyDirectivesToNode`.

This also changes the "$compile transclude should make the result of a transclusion available to the
parent directive in post- linking phase (templateUrl)" unit test. It was testing that a parent
directive can see the content of transclusion in its pre-link function. That is IMHO wrong (as the
`ngTransclude` directive inserts the translusion in its linking function). This test was only passing because of
c173ca4128, which changed the behavior of the compiler to traverse
before executing the parent linking function. That was wrong and also caused the #3792 issue, which
this change fixes.

Closes #3792
Closes #3923
Closes #3935
Closes #3927
2013-09-30 15:30:29 -07:00
Colin Casey
4ff1a65031 fix(log): prevent logging undefined for $log in IE
Closes #1705
2013-09-27 16:44:21 -07:00
Brian Ford
c785267eb8 fix(jqLite): use get/setAttribute so that jqLite works on SVG nodes
jqLite previously used `elt.className` to add and remove classes from a DOM Node, but
because the className property is not writable on SVG elements, it doesn't work with
them. This patch replaces accesses to `className` with `get/setAttribute`.

`classList` was also considered as a solution, but because only IE10+ supports it, we
have to wait. :'(

The JqLiteAddClass/JQLiteRemoveClass methods are now also used directly by $animate
to work around the jQuery not being able to handle class modifications on SVG elements.

Closes #3858
2013-09-27 12:38:27 -07:00
jankuca
6a8edc1d43 fix($compile): collect ranges on multiple directives on one element
The problem was in keeping the values of `attrNameStart` and `attrNameEnd` between directive loop iterations which lead to the compiler looking for multi-element ranges for any directives that happened to be in the directive list after one that was applied on a range. For instance, having a ng-repeat-start and ng-class on a single element with ng-repeat being resolved first made the compiler look for an ng-repeat-end for both ng-repeat and ng-class because the `attrNameEnd` was not reset to a falsy value before the second iteration. As the result, an exception saying the block end element could not be found and the second directive was not actually applied.

Closes #4002
2013-09-26 15:01:35 -07:00
jankuca
31c56f5400 fix(ngRepeat): correctly track elements even when the collection is initially undefined
Previously if the collection model was set to undefined on the first digest,
the repeater would get confused and not use the correct tracking function
for associating model with dom elements in the repeater.

Closes #4145
Closes #3964
2013-09-25 09:42:01 -07:00
Chirayu Krishnappa
e2751292da test(ng-non-bindable): test sibling bindings
Ref: https://github.com/angular/angular.dart/blob/master/test/directives/ng_non_bindable_spec.dart
2013-09-20 23:55:23 -07:00
Chirayu Krishnappa
e2068ad426 fix(ng-bind-html): watch string value instead of wrapper
Ref: https://github.com/angular/angular.js/pull/4045

I have this sinking feeling that support this use case sort of
encourages binding to function that blindly trust some html.  For now,
I'm fixing the issue while I think about the use cases some more.

In the case of a function that performs any non-trivial work before
wrapping the value (e.g. the showdown filter in issue #3980, or the
binding to a simply wrapper function in issue #3932 if it did anything
meaty), this fix makes it "work" - but performance is going to suck -
you should bind to some other thing on scope that watches the actual
source and adjusts itself when that changes (e.g. the showdown filter.)
For the case of the wrapper in #3932, if one isn't performing
sanitization or some such thing - then you the developer has insight
into why that value is safe in that particular context - and it should
be available simply by name and not as a result of a function taking any
arbitrary input to make auditing of security a little saner.

Closes #3932, #3980
2013-09-20 16:30:20 -07:00
Brian Ford
5eb1fb6cb2 fix(ngInclude): don't break attribute bindings on ngInclude-ed element
BREAKING CHANGE: ngInclude's priority is now set to 1000

It's quite rare for anyone to depend on explicity directive priority,
but if a custom directive that needs to run before ngInclude exists,
it should have its priority checked and adjusted if needed.

Closes #3793
2013-09-20 14:11:12 -07:00
Chirayu Krishnappa
be0b485669 fix($parse): disallow access to window and dom in expressions 2013-09-17 18:15:49 -07:00
Chirayu Krishnappa
4b71bbc988 fix(test): fixed toThrow usage 2013-09-17 16:13:25 -07:00
Gowtam Lal
aa3c54c73f fix(ngOptions): ignore object properties which start with $ 2013-09-13 12:48:19 +01:00
Matias Niemelä
36ad40b18c fix(ngAnimate): ensure that ngClass is always compiled before enter, leave and move animations
Closes #3727
Closes #3603
2013-09-03 17:06:49 -07:00
Matias Niemelä
4e15c4fb47 chore($rootScope): provide support to execute a function after the digest cycle is complete 2013-09-03 17:06:49 -07:00
Matias Niemelä
4382df03fa fix(ngAnimate): cut down on extra $timeout calls 2013-09-03 17:06:49 -07:00
jankuca
8e48c4ff6a fix($http): allow empty responses to be cached
Closes #3809
2013-09-02 11:47:51 +02: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
Igor Minar
e86de0db56 test(Scope): fix tests after reverting commits
Making assertions on state (rather than interactions) is better anyway.
2013-08-27 22:36:23 -07:00
Igor Minar
4114f9c21b revert: feat(mocks): make $timeout#flush throw an exception when empty
This reverts commit cbf06a5d64.

This turned out to be a bad idea because it allow us to fast-forward
the wall clock time (see previous commit).
2013-08-27 17:23:36 -07:00
Igor Minar
6b91aa0a18 feat(Scope): async auto-flush $evalAsync queue when outside of $digest
This change causes a new $digest to be scheduled in the next tick if
a task was was sent to the $evalAsync queue from outside of a $digest
or an $apply.

While this mode of operation is not common for most of the user code,
this change means that $q promises that utilze $evalAsync queue to
guarantee asynchronicity of promise apis will now also resolve outside
of a $digest, which turned out to be a big pain point for some developers.

The implementation ensures that we don't do more work than needed and
that we coalese as much work as possible into a single $digest.

The use of $browser instead of setTimeout ensures that we can mock out
and control the scheduling of "auto-flush", which should in theory
allow all of the existing code and tests to work without negative
side-effects.

Closes #3539
Closes #2438
2013-08-26 09:06:25 -07:00
Igor Minar
cbf06a5d64 feat(mocks): make $timeout#flush throw an exception when empty
When calling $timeout.flush with or without a delay an exception should
be thrown if there is nothing to be flushed.

This prevents tests from flushing stuff unnecessarily.

BREAKING CHANGE: calling $timeout.flush(delay) when there is no task to be flushed
within the delay throws an exception now.

Please adjust the delay or remove the flush call from your tests as the exception
is a signed of a programming error.
2013-08-25 14:46:54 -07:00
Igor Minar
5d9f42050a fix($q): reject should catch & forward exceptions thrown in errback 2013-08-24 12:49:46 -07:00
Vojta Jina
b89a4e49b9 test: rename / remove duplicate unit tests 2013-08-23 12:43:42 -07:00
Dusan Bartos
eefcdad013 fix($sniffer): history problems on Boxee box
History API not working properly on Boxee box browser (old Webkit)
problem similar to the one on Android < 4
2013-08-23 11:57:55 -07:00
Chirayu Krishnappa
699f86c535 revert: fix($sce): allow IE7 standards mode to pass non-quirks mode test
This reverts commit 637c9b1611.
(ref #3633 and #3646)

The minimum bar for $sce is IE8 in standards mode.  IE7 standards mode
is not supported.  If you must support IE7, you should disable $sce
completely.

  angular.module('ie7support', []).config(function($sceProvider) {
    // Completely disable SCE to support IE7.
    $sceProvider.enabled(false);
  });
2013-08-22 18:42:21 -07:00
Brian Ford
7d188d630c fix($q): fix forwarding resolution when callbacks aren't functions
Uses the changes from @jamestalmage's fix in #3535. (thanks!)

Closes #3535
2013-08-21 16:58:40 -07:00
justinrknowles
637c9b1611 fix($sce): allow IE7 standards mode to pass non-quirks mode test
Changes documentMode test version to 7 in order to support IE 8 in IE 7 standards
mode while still protecting against quirks mode.

documentMode returns the following values:
5 - quirks mode,
7 - IE 7 standards mode,
8 - IE 8 standards mode.

Closes #3633
Closes #3646
2013-08-21 01:38:39 -07:00
Igor Minar
eed299a31b fix(ngTransclude): clear the translusion point before transcluding
when the transluded content is being teleported to the translusion point, we should ensure that
the translusion point is empty before appending otherwise we end up with junk before the transcluded
content
2013-08-20 23:31:38 -07:00
Igor Minar
bf79bd4194 fix(ngTransclude): make the transclusion available to parent post-link
previously the translusion was appended the the ngTranslude element via
$evalAsync which makes the transluded dom unavailable to parent
post-linking functions. By appending translusion in linking phase,
post-linking functions will be able to access it.
2013-08-20 23:31:38 -07:00