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

fix($compile): remove the preAssignBindingsEnabled flag #15782

Closed
wants to merge 1 commit into from

Conversation

mgol
Copy link
Member

@mgol mgol commented Mar 6, 2017

BREAKING CHANGE:

Previously, the $compileProvider.preAssignBindingsEnabled flag was supported.
To migrate your code:

  1. If you specified $compileProvider.preAssignBindingsEnabled(false), you
    can remove that statement - since AngularJS 1.6.0 this is the default so your
    app should still work even in AngularJS 1.6 after such removal. Afterwards,
    migrating to AngularJS 1.7.0 shouldn't require any further action.

  2. If you specified $compileProvider.preAssignBindingsEnabled(true), first
    migrate your code so that the flag can be flipped to false. The instructions
    on how to do that are available in the "Migrating from 1.5 to 1.6" guide:
    https://docs.angularjs.org/guide/migration#migrating-from-1-5-to-1-6

What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
Feature removal.

What is the current behavior? (You can also link to an open issue here)
The $compileProvider.preAssignBindingsEnabled flag is supported.

What is the new behavior (if this is a feature change)?
The $compileProvider.preAssignBindingsEnabled flag doesn't exist.

Does this PR introduce a breaking change?
Yes.

Please check if the PR fulfills these requirements

Other information:
It is strongly advised to view this pull request with ?w=1 in the query string i.e. at https://github.com/angular/angular.js/pull/15782/files?w=1. Unfortunately, it's impossible to insert comments in this view.

@Narretz
Copy link
Contributor

Narretz commented Mar 8, 2017

Can you please add to the commit message a short explanation of what preAssignBindingsEnabled did?
and I've marked "removal" commits as "fix" instead of "feat" - we should probably be consistent here, but I'm not sure whats' better.
Otherwise LGTM

@mgol mgol changed the title feat($compile): remove the preAssignBindingsEnabled flag fix($compile): remove the preAssignBindingsEnabled flag Mar 9, 2017
@mgol
Copy link
Member Author

mgol commented Mar 9, 2017

@Narretz PR updated; how does it look now? (I only changed the commit message)

@frederikprijck
Copy link
Contributor

frederikprijck commented Mar 10, 2017

@mgol As I was reading through this I was wondering if this a typo:

If you specified $compileProvider.preAssignBindingsEnabled(true), you
can remove that statement - since AngularJS 1.6.0 this is the default so your
app should still work even in AngularJS 1.6 after such removal. Afterwards,
migrating to AngularJS 1.7.0 shouldn't require any further action.

Doesn't this have to be: $compileProvider.preAssignBindingsEnabled(false) (so false instead of true in both commit msg and PR description)?

@mgol
Copy link
Member Author

mgol commented Mar 10, 2017 via email

@Narretz
Copy link
Contributor

Narretz commented Mar 11, 2017

Can you add 1. if you haven't invoked $compileProvider.preAssignBindingsEnabled() you don't have to do anything to migrate.

@mgol
Copy link
Member Author

mgol commented Mar 11, 2017

Will do.

@mgol
Copy link
Member Author

mgol commented Mar 11, 2017

Commit message updated, PTAL.

Copy link
Member

@gkalpak gkalpak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code LGTM.

I believe we could simplify things a little more in $compile (e.g. by not using the "lazy" path for controller instantiation). And potentially drop that path in $controller altogether.
But this doesn't have to be part of this PR.

WRT the commit message:

  • It helps (when creating the changelog) to wrap code in backticks (e.g. $compile.preAssignBindingsEnabled and $onInit in the first paragraph).

  • In (2) $compileProvider.preAssignBindingsEnabled(true) should use false, not true.

BREAKING CHANGE:

Previously, the `$compileProvider.preAssignBindingsEnabled` flag was supported.
The flag controlled whether bindings were available inside the controller
constructor or only in the `$onInit` hook. The bindings are now no longer
available in the constructor.

To migrate your code:

1. If you haven't invoked `$compileProvider.preAssignBindingsEnabled()` you
don't have to do anything to migrate.

2. If you specified `$compileProvider.preAssignBindingsEnabled(false)`, you
can remove that statement - since AngularJS 1.6.0 this is the default so your
app should still work even in AngularJS 1.6 after such removal. Afterwards,
migrating to AngularJS 1.7.0 shouldn't require any further action.

3. If you specified `$compileProvider.preAssignBindingsEnabled(true)` you need
to first migrate your code so that the flag can be flipped to `false`. The
instructions on how to do that are available in the "Migrating from 1.5 to 1.6"
guide:
https://docs.angularjs.org/guide/migration#migrating-from-1-5-to-1-6
Afterwards, remove the `$compileProvider.preAssignBindingsEnabled(true)`
statement.
@mgol
Copy link
Member Author

mgol commented Mar 12, 2017

@gkalpak Yeah, this PR is already big due to all the indentation changes so I didn't want to introduce logic changes at this point. I'll happily look into it further once this lands (any regressions in such updates will be easier to revert).

Commit message updated.

@gkalpak
Copy link
Member

gkalpak commented Mar 13, 2017

LGTM

1 similar comment
@Narretz
Copy link
Contributor

Narretz commented Mar 14, 2017

LGTM

@mgol mgol added this to the 1.7.0 milestone Mar 15, 2017
@mgol mgol closed this in 38f8c97 Mar 15, 2017
@mgol mgol deleted the pre-assign-removal branch March 15, 2017 14:39
@edmorley
Copy link

There is a typo in the PR description - bullet 1's $compileProvider.preAssignBindingsEnabled(true) should be $compileProvider.preAssignBindingsEnabled(false). (In case anyone comes across this PR rather than reading the migration docs first, like I did :-))

@gkalpak
Copy link
Member

gkalpak commented May 21, 2018

Good catch! Thx for pointing it out.
It was fixed in the commit message, but not the PR description. Fixed it now.

thorn0 added a commit to thorn0/angular.js that referenced this pull request May 26, 2018
Now that we don't need to support `preAssignBindingsEnabled` (removed in angular#15782), complexity introduced in `$controller` by angular#7645 can be removed.
thorn0 added a commit to thorn0/angular.js that referenced this pull request May 26, 2018
Now that we don't need to support `preAssignBindingsEnabled` (removed in angular#15782), complexity introduced in `$controller` by angular#7645 can be removed.
thorn0 added a commit to thorn0/angular.js that referenced this pull request May 26, 2018
Now that we don't need to support `preAssignBindingsEnabled` (removed in angular#15782), complexity introduced in `$controller` by angular#7645 can be removed.
thorn0 added a commit to thorn0/angular.js that referenced this pull request May 28, 2018
Now that we don't need to support `preAssignBindingsEnabled` (removed in angular#15782), complexity introduced in `$controller` by angular#7645 can be removed.
thorn0 added a commit to thorn0/angular.js that referenced this pull request May 29, 2018
Now that we don't need to support `preAssignBindingsEnabled` (removed in angular#15782),
complexity introduced in `$controller` by angular#7645 can be removed.
thorn0 added a commit to thorn0/angular.js that referenced this pull request May 30, 2018
Now that we don't need to support `preAssignBindingsEnabled` (removed in angular#15782),
complexity introduced in `$controller` by angular#7645 can be removed.

One difference with the previous implementation is that all non-ES2015-class controller instances
were available on the element before calling their constructors. Now it depends on the relative
order of controllers. Controller constructors shouldn't be used to access other controllers
(e.g. via `$element.controller(directiveName)`). The recommended way is to use the `require` property
of the directive definition object and the life cycle hooks `$onChanges` or `$onInit`.

See
https://docs.angularjs.org/api/ng/service/$compile#-require-
https://docs.angularjs.org/api/ng/service/$compile#life-cycle-hooks
thorn0 added a commit to thorn0/angular.js that referenced this pull request May 30, 2018
Now that we don't need to support `preAssignBindingsEnabled` (removed in angular#15782),
complexity introduced in `$controller` by angular#7645 can be removed.

One difference with the previous implementation is that all non-ES2015-class controller instances
were available on the element before calling their constructors. Now it depends on the relative
order of controllers. Controller constructors shouldn't be used to access other controllers
(e.g. via `$element.controller(directiveName)`). The recommended way is to use the `require`
property of the directive definition object and the life cycle hooks `$onChanges` or `$onInit`.

See
https://docs.angularjs.org/api/ng/service/$compile#-require-
https://docs.angularjs.org/api/ng/service/$compile#life-cycle-hooks
gkalpak pushed a commit that referenced this pull request May 30, 2018
Now that we don't need to support `preAssignBindingsEnabled` (removed in #15782),
complexity introduced in `$controller` by #7645 can be removed.

One difference with the previous implementation is that all non-ES2015-class controller instances
were available on the element before calling their constructors. Now it depends on the relative
order of controllers. Controller constructors shouldn't be used to access other controllers
(e.g. via `$element.controller(directiveName)`). The recommended way is to use the `require`
property of the directive definition object and the life cycle hooks `$onChanges` or `$onInit`.

See
https://docs.angularjs.org/api/ng/service/$compile#-require-
https://docs.angularjs.org/api/ng/service/$compile#life-cycle-hooks

Closes #16580
gkalpak pushed a commit that referenced this pull request May 30, 2018
Now that we don't need to support `preAssignBindingsEnabled` (removed in #15782),
complexity introduced in `$controller` by #7645 can be removed.

One difference with the previous implementation is that all non-ES2015-class controller instances
were available on the element before calling their constructors. Now it depends on the relative
order of controllers. Controller constructors shouldn't be used to access other controllers
(e.g. via `$element.controller(directiveName)`). The recommended way is to use the `require`
property of the directive definition object and the life cycle hooks `$onChanges` or `$onInit`.

See
https://docs.angularjs.org/api/ng/service/$compile#-require-
https://docs.angularjs.org/api/ng/service/$compile#life-cycle-hooks

Closes #16580
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants