Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Commit

Permalink
fix(loader): use false as default value for transclude in compone…
Browse files Browse the repository at this point in the history
…nt helper

The default value of for transclude in component helper is now `false`.

The change is motivated by the fact that using `transclude: true` when not necessary
made component unusable in conjunction with structural directives that also require
transclusion such as `ng-switch-when` and `ng-repeat`.

Closes #13566
Closes #13581

BREAKING CHANGE:
Angular 1.5.0.beta.2 introduced the `module.component` helper where `transclude` was true by default.
This changes the default for `transclude` to `false`. If you created components that expected
transclusion then you must change your code to specify `transclude: true`.
  • Loading branch information
sarod authored and petebacondarwin committed Jan 4, 2016
1 parent b0248b7 commit 6a47c0d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/loader.js
Expand Up @@ -318,7 +318,7 @@ function setupModuleLoader(window) {
* - `bindings` – `{object=}` – Define DOM attribute binding to component properties.
* Component properties are always bound to the component controller and not to the scope.
* - `transclude` – `{boolean=}` – Whether {@link $compile#transclusion transclusion} is enabled.
* Enabled by default.
* Disabled by default.
* - `isolate` – `{boolean=}` – Whether the new scope is isolated. Isolated by default.
* - `restrict` - `{string=}` - String of subset of {@link ng.$compile#-restrict- EACM} which
* restricts the component to specific directive declaration style. If omitted, this defaults to 'E'.
Expand All @@ -331,7 +331,7 @@ function setupModuleLoader(window) {
* definitions are very simple and do not require the complexity behind defining directives.
* Component definitions usually consist only of the template and the controller backing it.
* In order to make the definition easier, components enforce best practices like controllerAs
* and default behaviors like scope isolation, restrict to elements and allow transclusion.
* and default behaviors like scope isolation, restrict to elements.
*
* <br />
* Here are a few examples of how you would usually define components:
Expand Down Expand Up @@ -420,7 +420,7 @@ function setupModuleLoader(window) {
controllerAs: identifierForController(options.controller) || options.controllerAs || name,
template: makeInjectable(template),
templateUrl: makeInjectable(options.templateUrl),
transclude: options.transclude === undefined ? true : options.transclude,
transclude: options.transclude === undefined ? false : options.transclude,
scope: options.isolate === false ? true : {},
bindToController: options.bindings || {},
restrict: options.restrict || 'E'
Expand Down
6 changes: 3 additions & 3 deletions test/loaderSpec.js
Expand Up @@ -121,7 +121,7 @@ describe('component', function() {
controllerAs: 'myComponent',
template: '',
templateUrl: undefined,
transclude: true,
transclude: false,
scope: {},
bindToController: {},
restrict: 'E'
Expand All @@ -136,7 +136,7 @@ describe('component', function() {
controllerAs: 'ctrl',
template: 'abc',
templateUrl: 'def.html',
transclude: false,
transclude: true,
isolate: false,
bindings: {abc: '='},
restrict: 'EA'
Expand All @@ -148,7 +148,7 @@ describe('component', function() {
controllerAs: 'ctrl',
template: 'abc',
templateUrl: 'def.html',
transclude: false,
transclude: true,
scope: true,
bindToController: {abc: '='},
restrict: 'EA'
Expand Down

0 comments on commit 6a47c0d

Please sign in to comment.