aboutsummaryrefslogtreecommitdiffstats
path: root/src/ng/compile.js
AgeCommit message (Collapse)Author
2014-03-18feat($compile): add support for $observer deregistrationCaio Cunha
In order to make the behavior compatible with $rootScope.$watch and $rootScope.$on methods, and make it possible to deregister an attribute observer, Attributes.$observe method now returns a deregistration function instead of the observer itself. BREAKING CHANGE: calling attr.$observe no longer returns the observer function, but a deregistration function instead. To migrate the code follow the example below: Before: ``` directive('directiveName', function() { return { link: function(scope, elm, attr) { var observer = attr.$observe('someAttr', function(value) { console.log(value); }); } }; }); ``` After: ``` directive('directiveName', function() { return { link: function(scope, elm, attr) { var observer = function(value) { console.log(value); }; attr.$observe('someAttr', observer); } }; }); ``` Closes #5609
2014-03-07fix($compile): support templates with thead and tfoot root elementsLucas Galfasó
If the first element in a template is a <thead> or a <tfoot>, then use the existing logic to handle table elements compilation. Closes #6289
2014-02-27docs($compile): fix typoLajos Veres
2014-02-26docs(*): fix jsdoc type expressionsPeter Bacon Darwin
These errors in the docs were preventing some parts of the docs from being parsed.
2014-02-21docs(*): fix anchors for members in api docsPeter Bacon Darwin
2014-02-16docs(bike-shed-migration): fix url-based links refs to AUTO modulePeter Bacon Darwin
2014-02-16docs(bike-shed-migration): fix invalid </file name=""> HTML in examplesPeter Bacon Darwin
2014-02-16docs(bike-shed-migration): convert <doc:...> examples to <example>...Peter Bacon Darwin
2014-02-16docs(all): convert <pre>/</pre> snippets to GFM snippetsCaitlin Potter
2014-02-16docs(bike-shed-migration): convert doctype and namesPeter Bacon Darwin
2014-02-14fix($animate): ensure $animate doesn't break natural CSS transitionsMatias Niemelä
BREAKING CHANGE: ngClass and {{ class }} will now call the `setClass` animation callback instead of addClass / removeClass when both a addClass/removeClass operation is being executed on the element during the animation. Please include the setClass animation callback as well as addClass and removeClass within your JS animations to work with ngClass and {{ class }} directives. Closes #6019
2014-02-14fix($compile) support templates with table content root nodesCaitlin Potter
If the first element in a template is a <tr>, <th>, <td>, or <tbody> tag, the HTML compiler will ensure that the template is wrapped in a <table> element so that the table content is not discarded. Closes #2848 Closes #1459 Closes #3647 Closes #3241
2014-02-10fix($compile): ensure element transclusion directives are linked with ↵Caitlin Potter
comment element This corrects a complicated compiler issue, described in detail below: Previously, if an element transclusion directive contained an asynchronous directive whose template contained another element transclusion directive, the inner element transclusion directive would be linked with the element, rather than the expected comment node. An example manifestation of this bug would look like so: ```html <div ng-repeat="i in [1,2,3,4,5]"> <div my-directive> </div> </div> ``` `my-directive` would be a replace directive, and its template would contain another element transclusion directive, like so: ```html <div ng-if="true">{{i}}</div> ``` ngIf would be linked with this template content, rather than the comment node, and the template element would be attached to the DOM, rather than the comment. As a result, this caused ng-if to duplicate the template when its expression evaluated to true. Closes #6006 Closes #6101
2014-02-04docs($compile): fixed syntax error.Kamil Pekala
"how to" was written twice in a row. Closes #6110
2014-01-31fix($compile): retain CSS classes added in cloneAttachFn on asynchronous ↵Caitlin Potter
directives Previously, classes added to asynchronous directive elements during the clone attach function would not persist after the node is merged with the template, prior to linking. This change corrects this behaviour and brings it in line with synchronous directives. Closes #5439 Closes #5617
2014-01-28test(docs): convert example end to end doc tests from scenario runner to ↵Julie
protractor Thanks to jeffbcross, petebacondarwin, btford, jdeboer, tbosch for contributions! Closes #6023
2014-01-06docs($compile): fix a typoGias Kay Lee
Closes #5639
2014-01-02docs($compile): fix typoDavid Burrows
Closes #5599
2013-12-19fix($compile): remove invalid IE exceptional case for `href`Alexandre Potvin Latreille
It appears that this exceptional case was only valid for IE<8 and that for IE>=8 it was actually causing a bug with the `ng-href-attr` directive on `<a>` elements. Closes #5479
2013-12-18perf(compile): add class 'ng-scope' before cloning and other micro-optimizationsKarl Seamon
Add class ng-scope to dom nodes during directive compile rather than link. Optimize handling of nodeLists. This results in a savings of about 130ms during the startup of a product within Google. Closes #5471
2013-12-18docs($compile): fix param name and improve example variable nameKindy Lin
Closes #5310
2013-12-13perf(jqLite): implement and use the `empty` method in place of `html(‘’)`Michał Gołębiowski
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-12fix($compile): Allow literals in isolate scope referencesTobias Bosch
When a component uses an isolate scope reference and the the component is used with an object literal a new object is created on every evaluation. Therefore the compiler needs to compare the values of the parent and the isolate scope using object equality and not object reference equality. Fixes #5296.
2013-12-05fix($compile): update cloned elements if the template arrives after the cloningTobias Bosch
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-04fix($compile): ensure isolated local watches' lastValue is always in syncDaniel Tabuenca
When using two-way binding with isolate scope, under some circumstances the lastValue variable captured in the parentValueWatch function can get out of sync. Specifically, if both the value in the origin scope as well as the value in the isolate scope get independently updated to the same value within one digest cycle, the lastValue is never updated. This potentially causes the watch to make the wrong decision as to which side to update on subsequent passes. This fixes things by ensuring lastValue is always set to the last seen value even if the watch's logic was short circuited because there was no difference between the values in the original and isolate scopes. Closes #5182
2013-11-27docs($compile): fix missing spaceStéphane Reynaud
2013-11-26fix($sanitize): Use same whitelist mechanism as $compile does.Tobias Bosch
`$sanitize` now uses the same mechanism as `$compile` to validate uris. By this, the validation in `$sanitize` is more general and can be configured in the same way as the one in `$compile`. Changes - Creates the new private service `$$sanitizeUri`. - Moves related specs from `compileSpec.js` into `sanitizeUriSpec.js`. - Refactors the `linky` filter to be less dependent on `$sanitize` internal functions. Fixes #3748.
2013-11-26docs(compile): fix typoadam77
Closes #5133
2013-11-21fix($compile): secure form[action] & iframe[srcdoc]Chirayu Krishnappa
Require bindings to form[action] to be $sce.RESOURCE_URL and bindings to iframe[srcdoc] to be $sce.HTML Closes #4927 Closes #4933
2013-11-21fix($compile): ensure CSS classes are added and removed only when necessaryMatias Niemelä
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-20fix(ngClass): ensure that ngClass only adds/removes the changed classesMatias Niemelä
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-14fix($compile): accessing controllers of transcluded directives from childrenTobias Bosch
Additional API (backwards compatible) - Injects `$transclude` (see directive controllers) as 5th argument to directive link functions. - `$transclude` takes an optional scope as first parameter that overrides the bound scope. Deprecations: - `transclude` parameter of directive compile functions (use the new parameter for link functions instead). Refactorings: - Don't use comment node to temporarily store controllers - `ngIf`, `ngRepeat`, ... now all use `$transclude` Closes #4935.
2013-11-14refactor($compile): move function def out of loopTobias Bosch
2013-11-13docs($compile): Explain that post-link functions run in reverse order.Martin Field
Update the $compile docs to mention the change introduced in #4266. Closes #4843
2013-11-12fix($compile): correctly handle interpolated style in replace templatesTobias Bosch
A directive with a template with `replace: true` and an interpolated style at the root element should work correctly. Closes #4882.
2013-11-07feat(jqLite): expose isolateScope() getter similar to scope()Igor Minar
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-07fix($compile): don't leak isolate scope state when replaced directive is ↵Igor Minar
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-07fix($compile): correct isolate scope distribution to controllersIgor Minar
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-07fix($compile): replaced element has isolate scopeMisko Hevery
2013-11-07fix($compile): only pass isolate scope to children that belong to the ↵Vojta Jina
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-07fix($compile): make isolate scope truly isolateVojta Jina
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-10-30chore($compile): remove special case for ngIf and ngRepeatBrian Ford
2013-10-30fix(ngIf): ngIf removes elements dynamically added to itBrian Ford
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-28fix($compile): don't instantiate controllers twice for element transclude ↵Igor Minar
directives This is a fix for regression introduced last week by faf5b980. Closes #4654
2013-10-25fix($compile): attribute bindings should not break due to terminal directivesIgor Minar
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-25docs(compile): fix typo in 'Attributes' descriptionBrainCrumbz
Closes #4589
2013-10-24fix($compile): instantiate controlers when re-entering compilationIgor Minar
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-23docs(guide/directive,guide/compiler,): drastically improveBrian Ford
2013-10-22style: make jshint happyVojta Jina
2013-10-18docs: correct broken linksVojta Jina
This also contains some whitespace corrections by my editor.