Commit graph

1448 commits

Author SHA1 Message Date
Vojta Jina
4ab16aaaf7 feat($parse): revert hiding "private" properties
Hiding `_*` properties was a feature primarily for developers using Closure compiler and Google JS
style. We didn't realize how many people will be affected by this change.

We might introduce this feature in the future, probably under a config option, but it needs more
research and so I'm reverting the change for now.

This reverts commit 3d6a89e888.

Closes #4926
Closes #4842
Closes #4865
Closes #4859
Closes #4849

Conflicts:
	src/ng/parse.js
2013-11-13 23:25:09 -08:00
Jeff Cross
89f435de84 fix(urlUtils): made removal of windows drive from path safer
Prior to this fix, the urlResolve method would automatically
strip the first segment of a path if the segment ends in a colon.
This was to correct undesired behavior in the $location service
using the file protocol on windows in multiple browsers (see #4680).

However, there could be cases where users intentionally 
have first path segments that end in a colon 
(although this conflicts with section 3.3 of rfc3986).

The solution to this problem is an extra check to make sure
the first path segment of the input url does not end with a colon,
to make sure we're only removing undesired path segments.

Fixes #4939
2013-11-13 15:53:20 -08:00
Ben Wiklund
f69ee170ed docs($httpBackendSpec): fix typo in spy name
Closes #4830
2013-11-13 21:21:50 +00:00
ROUL
f925e8caa6 fix(urlUtils): urlUtils doesn't return right path for file:// on win
Chrome and other browsers on Windows often
append the drive name to the pathname,
as described in #4680. This would cause
the location service to browse to odd
URLs, such as /C:/myfile.html,
when opening apps using file://.

Fixes  #4680
2013-11-12 22:41:06 -08:00
Tobias Bosch
e1254b266d fix($compile): correctly handle interpolated style in replace templates
A directive with a template with `replace: true` and an interpolated style at the root element should work correctly.

Closes #4882.
2013-11-12 16:51:16 -08:00
Tobias Bosch
4612705ec2 fix(ngIf): don't create multiple elements when changing from a truthy to another thruthy value.
Fixes #4852.
2013-11-11 17:05:43 -08:00
Chirayu Krishnappa
9577702e8d fix($resource): don't use $parse for @dotted.member
params and paramDefaults support looking up the parameter value from the
data object.  The syntax for that is `@nested.property.name`.
Currently, $resource uses $parse to do this.  This is too liberal
(you can use values like `@a=b` or `@a | filter` and have it work -
which doesn't really make sense).  It also puts up a dependency on
$parse which is has restrictions to secure expressions used in
templates.  The value here, though a string, is specified in Javascript
code and shouldn't have those restrictions.
2013-11-11 16:17:34 -08:00
Pete Bacon Darwin
aea76f0d5c fix(animateSpec): run digest to enable animations before tests 2013-11-08 01:03:18 -08:00
Pete Bacon Darwin
ffa9d0a6db fix(ngClassSpec): clear animation enable fn from postDigestQueue 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
Igor Minar
b5af198f0d fix($compile): don't leak isolate scope state when replaced directive is used multiple times
When an isolate scope directive is also a "replace" directive and at the root of its template
it has other directives, we need to keep track remember to use isolate scope when linking
these.

This commit fixes the leakage of this state when this directive is used again later inside
or outside of the isolate directive template.
2013-11-07 22:08:05 -08:00
Igor Minar
3fe4491a6b fix($compile): correct isolate scope distribution to controllers
Fixes an issue when we didn't share the isolate scope with the controller
of the directive from the isolate directive's template when this directive
was replaced onto the isolate directive element.
2013-11-07 22:08:05 -08:00
Misko Hevery
97c7a4e379 fix($compile): replaced element has isolate scope 2013-11-07 22:08:05 -08:00
Vojta Jina
d0efd5eefc fix($compile): only pass isolate scope to children that belong to the isolate directive
I had to fix one unit test, as it assumed the broken behavior, where application template gets the
isolate scope of other (isolate) directive, rather than the regular scope.

BREAKING CHANGE: Child elements that are defined either in the application template or in some other
directives template do not get the isolate scope. In theory, nobody should rely on this behavior, as
it is very rare - in most cases the isolate directive has a template.
2013-11-07 22:08:04 -08:00
Vojta Jina
909cabd36d fix($compile): make isolate scope truly isolate
Fixes issue with isolate scope leaking all over the place into other directives on the same element.

Isolate scope is now available only to the isolate directive that requested it and its template.

A non-isolate directive should not get the isolate scope of an isolate directive on the same element,
instead they will receive the original scope (which is the parent scope of the newly created isolate scope).

Paired with Tobias.

BREAKING CHANGE: Directives without isolate scope do not get the isolate scope from an isolate directive on the same element. If your code depends on this behavior (non-isolate directive needs to access state from within the isolate scope), change the isolate directive to use scope locals to pass these explicitly.

// before
<input ng-model="$parent.value" ng-isolate>

.directive('ngIsolate', function() {
  return {
    scope: {},
    template: '{{value}}'
  };
});

// after
<input ng-model="value" ng-isolate>

.directive('ngIsolate', function() {
  return {
    scope: {value: '=ngModel'},
    template: '{{value}}
  };
});

Closes #1924
Closes #2500
2013-11-07 22:03:19 -08:00
Jeff Cross
da344daa40 fix(ngView): only run anchorScroll after animation is done 2013-11-06 00:14:11 -08:00
Pete Bacon Darwin
d378f5500a fix(ngInclude): only run anchorScroll after animation is done
We need to wait until animations have added the content to the document before
trying to `autoscroll` to anchors that may have been inserted.

Fixes #4723
2013-11-06 00:14:11 -08:00
Matias Niemelä
9470080762 fix($animate): only apply the fallback property if any transition animations are detected 2013-11-06 02:01:19 -05:00
Matias Niemelä
9d69a0a7c7 feat($animate): ensure CSS transitions can work with inherited CSS class definitions
BREAKING CHANGE

ngAnimate addClass / removeClass animations are now applied right away. This means
that as soon as the animation starts the class will be added (addClass) or removed
(removeClass) to the element being animated instead of after the -add-active /
-remove-active animations are completed. This allows for animations outside of
ngAnimate to not conflict with $animate.

This commit introduces beforeAddClass and beforeRemoveClass animation event functions and
executes any addClass and removeClass event functions AFTER the class has been added or
removed (this is opposite functionality of how ngAnimate used to work when performing
JS-enabled animations addClass / removeClass animations). If your animation code relies on
any animations being performed prior to the class change then simply use the new
beforeAddClass and beforeRemoveClass animation event functions.

Finally, when animating show and hide animations using CSS transitions or keyframe animations,
ng-hide-remove doesn't require `display:block!important` for ng-hide-add anymore.
2013-11-05 21:15:59 -08:00
Matias Niemelä
7d2d2575a2 chore(animateSpec): provide meaningful CSS class names in animation tests 2013-11-05 21:46:07 -05:00
Matias Niemelä
b89584db10 fix($animate): avoid hanging animations if the active CSS transition class is missing
Closes #4732
Closes #4490
2013-11-05 21:45:36 -05:00
Matias Niemelä
41a2d5b30f fix($animate): ensure staggering animations understand multiple delay values 2013-11-05 21:44:25 -05:00
Matias Niemelä
e53ff431e1 fix($animate): ensure the active class is not applied if cancelled during reflow
Closes #4699
2013-11-05 21:44:02 -05:00
Matias Niemelä
974b6d4a5b chore($sniffer): make msie variable public
The msie variable is a global variable used within the ng core which contains the
version number for the current Internet Explorer browser that is rendering the
application. Other modules outside of the ng core could make use of this variable
instead of having to rollout duplicate detection code. This code makes it easy to
reuse this simple property within the $sniffer service.
2013-11-05 21:43:31 -05:00
Matias Niemelä
952fea69fb chore(ngAnimate): ensure elapsedTime values are in seconds and millseconds 2013-11-05 21:42:42 -05:00
Igor Minar
8f989d652f fix(ngModel): deregister from the form on scope not DOM destruction
Due to animations, DOM might get destroyed much later than scope and so the element $destroy event
might get fired outside of $digest, which causes changes to the validation model go unobserved
until the next digest. By deregistering on scope  event, the deregistration always happens
in $digest and the form validation model changes will be observed.

Closes #4226
Closes #4779
2013-11-04 10:35:51 -08:00
Igor Minar
9483373c33 fix(ngIf): destroy child scope when destroying DOM 2013-11-04 10:35:51 -08:00
Chirayu Krishnappa
3d6a89e888 feat($parse): secure expressions by hiding "private" properties
BREAKING CHANGE:
This commit introduces the notion of "private" properties (properties
whose names begin and/or end with an underscore) on the scope chain.
These properties will not be available to Angular expressions (i.e. {{
}} interpolation in templates and strings passed to `$parse`)  They are
freely available to JavaScript code (as before).

Motivation
----------
Angular expressions execute in a limited context.  They do not have
direct access to the global scope, Window, Document or the Function
constructor.  However, they have direct access to names/properties on
the scope chain.  It has been a long standing best practice to keep
sensitive APIs outside of the scope chain (in a closure or your
controller.)  That's easier said that done for two reasons: (1)
JavaScript does not have a notion of private properties so if you need
someone on the scope chain for JavaScript use, you also expose it to
Angular expressions, and (2) the new "controller as" syntax that's now
in increased usage exposes the entire controller on the scope chain
greatly increaing the exposed surface.  Though Angular expressions are
written and controlled by the developer, they (1) typically deal with
user input and (2) don't get the kind of test coverage that JavaScript
code would.  This commit provides a way, via a naming convention, to
allow publishing/restricting properties from controllers/scopes to
Angular expressions enabling one to only expose those properties that
are actually needed by the expressions.
2013-10-30 17:01:51 -07:00
Brian Ford
e19067c9bb fix(ngIf): ngIf removes elements dynamically added to it
When using ngIf with ngInclude on the same element, ngIf previously did not remove
elements added by ngInclude. Similarly, when using ngIfStart/End, ngIf will miss
elements added between the start/end markers added after ngIf is linked.

This commit changes the behavior of ngIf to add a comment node at the end of its
elements such that elements between the starting comment and this ending comment
are removed when ngIf's predicate does not hold.
2013-10-30 16:21:02 -07:00
Matias Niemelä
d434eabec3 fix($animate): use direct DOM comparison when checking for $rootElement
Closes #4679
2013-10-28 22:47:47 -07:00
Matias Niemelä
7f0767acab fix($animate): ensure former nodes are fully cleaned up when a follow-up structural animation takes place
Closes #4435
2013-10-28 21:26:35 -07:00
Matias Niemelä
6818542c69 fix($animate): ensure enable/disable animations work when the document node is used
Closes #4669
2013-10-28 14:26:07 -07:00
Matias Niemelä
7484830744 feat(ngAnimate): provide support for staggering animations with CSS 2013-10-28 15:00:47 -06:00
Igor Minar
18ae985c3a fix($compile): don't instantiate controllers twice for element transclude directives
This is a fix for regression introduced last week by faf5b980.

Closes #4654
2013-10-28 01:11:18 -07:00
Igor Minar
797c99eabe style(compileSpec): reorder and cleanup tests for $compile's transclusion feature 2013-10-28 01:11:17 -07:00
Igor Minar
79223eae50 fix($compile): attribute bindings should not break due to terminal directives
Recently we changed the priority of attribute interpolation directive to -100
to ensure that it executes early in the post linking phase. This causes issues
with when terminal directives are placed on elements with attribute bindings
because the terminal directive will usually have 0 or higher priority which
results in attr interpolation directive not being applied to the element.

To fix this issue I'm switching the priority back to 100 and making moving the
binding setup into the pre-linking function.

This means that:

- terminal directives with priority lower than 100 will not affect the attribute
  binding
- if a directive wants to add or alter bindings it can do so in the pre-linking
  phase, as long as the priority of this directive is more than 100
- all post-linking functions will execute after the attribute binding has been
  set up
- all pre-linking functions with directive priority lower than 100 will execute
  after the attribute bindings have been setup

BREAKING CHANGE: the attribute interpolation (binding) executes as a directive
with priority 100 and the binding is set up in the pre-linking phase. It used
to be that the priority was -100 in rc.2 (100 before rc.2) and that the binding
was setup in the post-linking phase.

Closes #4525
Closes #4528
Closes #4649
2013-10-25 14:19:58 -07:00
Arun Israel
280354c3f9 style(injectorSpec): fix typo in "it" description
Closes #4483
2013-10-25 21:52:46 +01:00
Matias Niemelä
76b628bcb3 fix($animate): skip unnecessary addClass/removeClass animations
Skip addClass animations if the element already contains the class that is being
added to element. Also skip removeClass animations if the element does not contain
the class that is being removed.

Closes #4401
Closes #2332
2013-10-24 17:35:57 -04:00
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