No description
Find a file
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
css fix(ngShowHide): change the .ng-hide CSS class to use an !important flag 2013-08-02 23:55:53 -07:00
docs docs(guide): describe directive replace:false 2013-09-30 22:51:01 +01:00
example docs(examples): set ng-app to "personalLog" (example/personalLog) 2013-04-11 14:53:40 -07:00
i18n chore(i18n): update path in the generate.sh script 2013-08-27 15:56:38 -07:00
images chore(Grunt): switch from Rake to Grunt 2013-03-05 23:00:33 -08:00
lib chore(grunt): support semver v2 version number format 2013-09-04 14:50:39 +02:00
logs creating logs/ and tmp/ dirs 2010-10-29 10:47:06 -07:00
src fix($compile): link parents before traversing 2013-09-30 15:30:29 -07:00
test fix($compile): link parents before traversing 2013-09-30 15:30:29 -07:00
.bowerrc chore(bower): add a .bowerrc file 2013-08-07 14:11:23 -07:00
.gitignore chore(tests): add Promises/A+ Test Suite to the build 2013-08-24 12:49:57 -07:00
.travis.yml chore(travis): run bower install twice to make sure it does 2013-08-28 17:48:46 -07:00
angularFiles.js chore: reorganize test helper files under test/helpers 2013-08-23 15:46:11 -07:00
bower.json fix($compile): work around issue in jQuery 1.10.2 2013-09-25 17:25:00 -07:00
changelog.js chore(changelog.js): pickup breaking changes f/ chore/refactor commits 2013-08-13 10:00:14 -07:00
CHANGELOG.md docs(changelog): add a note about directives ending w/ -start and -end 2013-09-05 01:31:34 +02:00
changelog.spec.js chore(changelog.js): improve the changelog script 2013-01-22 22:49:00 -08:00
changelog.tmp.md chore(release scripts): auto release scripts 2012-03-29 07:22:13 -07:00
check-size.sh chore(Grunt): switch from Rake to Grunt 2013-03-05 23:00:33 -08:00
compare-master-to-stable.js chore(release): add script for comparing master and stable branches 2013-09-05 01:15:36 +02:00
CONTRIBUTING.md docs(CONTRIBUTING.md): add contrib info file for GitHub 2012-11-25 21:00:14 +01:00
gdocs.js chore(formating): clean code to be function() { 2011-10-11 11:01:46 -07:00
gen_docs.sh chore(docs): get correct location for jasmine-node 2012-09-06 16:06:25 -07:00
Gruntfile.js fix(build): get promise A+ tests to run on windows 2013-09-17 13:38:52 +01:00
init-repo.sh docs(tutorial): testacular renamed to karma 2013-04-15 12:28:31 +01:00
jenkins_build.sh chore(build): add jenkins_build.sh file 2013-08-30 23:20:30 +02:00
karma-docs.conf.js chore(travis): clean up logs 2013-08-23 16:49:10 -07:00
karma-e2e.conf.js chore(travis): clean up logs 2013-08-23 16:49:10 -07:00
karma-jqlite.conf.js chore(travis): clean up logs 2013-08-23 16:49:10 -07:00
karma-jquery.conf.js chore(travis): clean up logs 2013-08-23 16:49:10 -07:00
karma-modules.conf.js chore(travis): clean up logs 2013-08-23 16:49:10 -07:00
karma-shared.conf.js chore(karma): longer reconnect timeout 2013-08-28 15:46:19 -07:00
LICENSE chore(license): update to google 2012-04-20 11:29:34 -07:00
package.json chore(package.json): update npm packages 2013-09-30 14:52:20 -07:00
README.md docs(README): add dashboard link 2013-09-09 12:26:22 +01:00
release-commit.sh chore(release scripts): auto release scripts 2012-03-29 07:22:13 -07:00
start-iteration.sh chore(release scripts): auto release scripts 2012-03-29 07:22:13 -07:00
travis_build.sh chore(travis): clean up the build output 2013-08-28 15:46:19 -07:00
travis_print_logs.sh chore(travis): clean up logs 2013-08-23 16:49:10 -07:00
validate-commit-msg.js docs(validate-commit-msg): fix incorrect comment 2013-06-04 20:23:51 +01:00
validate-commit-msg.spec.js fix(git-validator): support fixup and better errors 2013-01-17 23:52:46 -08:00
watchr-docs.rb chore(watchr): watchr scripts should output logs to terminal 2011-10-31 11:34:25 -07:00

AngularJS Build Status

AngularJS lets you write client-side web applications as if you had a smarter browser. It lets you use good old HTML (or HAML, Jade and friends!) as your template language and lets you extend HTMLs syntax to express your applications components clearly and succinctly. It automatically synchronizes data from your UI (view) with your JavaScript objects (model) through 2-way data binding. To help you structure your application better and make it easy to test, AngularJS teaches the browser how to do dependency injection and inversion of control. Oh yeah and it also helps with server-side communication, taming async callbacks with promises and deferreds; and make client-side navigation and deeplinking with hashbang urls or HTML5 pushState a piece of cake. The best of all: it makes development fun!

Building AngularJS

Once you have your environment setup just run:

grunt package

Running Tests

To execute all unit tests, use:

grunt test:unit

To execute end-to-end (e2e) tests, use:

grunt package
grunt test:e2e

To learn more about the grunt tasks, run grunt --help and also read our contribution guidelines.