Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

compiler: improve support for AngularJS 1.7.2+ #11319

Closed
@Splaktar

Description

@Splaktar

Bug, enhancement request, or proposal:

Proposal

CodePen and steps to reproduce the issue:

Demo which demonstrates the issue:

https://travis-ci.org/angular/material/jobs/388688438 is just one of many CI unit test jobs which have failed for the AngularJS SNAPSHOT view since angular/angular.js#16580 was merged.

What is the expected behavior?

AngularJS Material unit tests in master pass against the AngularJS SNAPSHOT version.

What is the current behavior?

54 failing tests can be seen in all recent jobs like https://travis-ci.org/angular/material/jobs/388688438.

What is the use-case or motivation for changing an existing behavior?

We were fairly well prepared for the changes in angular/angular.js#15782 that went into AngularJS 1.7.0, but the follow on breaking changes in angular/angular.js#16580 that are part of the unreleased AngularJS 1.7.1 remove some private and undocumented APIs that AngularJS Material depended upon.

One example is the use of the third and fourth arguments in $controller which were added to fix an issue with ES6 that we resolved in 1.1.5. You can see some of the comments that explain this here:

MdCompilerService.prototype._createController = function(options, injectLocals, locals) {
// The third and fourth arguments to $controller are considered private and are undocumented:
// https://github.com/angular/angular.js/blob/master/src/ng/controller.js#L86
// Passing `true` as the third argument causes `$controller` to return a function that
// gets the controller instance instead returning of the instance directly. When the
// controller is defined as a function, `invokeCtrl.instance` is the *same instance* as
// `invokeCtrl()`. However, then the controller is an ES6 class, `invokeCtrl.instance` is a
// *different instance* from `invokeCtrl()`.
var invokeCtrl = this.$controller(options.controller, injectLocals, true, options.controllerAs);
if (getPreAssignBindingsEnabled() && options.bindToController) {
angular.extend(invokeCtrl.instance, locals);
}
// Instantiate and initialize the specified controller.
var ctrl = invokeCtrl();
if (!getPreAssignBindingsEnabled() && options.bindToController) {
angular.extend(ctrl, locals);
}
// Call the $onInit hook if it's present on the controller.
angular.isFunction(ctrl.$onInit) && ctrl.$onInit();
return ctrl;
};
.

Which versions of AngularJS, Material, OS, and browsers are affected?

  • AngularJS: 1.7.1
  • AngularJS Material: All
  • OS: All
  • Browsers: All

Is there anything else we should know? Stack Traces, Screenshots, etc.

We cover some of the details of $compileProvider.preAssignBindingsEnabled() in our updated docs for 1.1.9 here: https://material.angularjs.org/latest/api/service/$mdCompilerProvider#mdcompilerprovider-respectpreassignbindingsenabled-respected

Metadata

Metadata

Assignees

Labels

P1: urgentUrgent issues that should be addressed in the next minor or patch release.for: internal contributorThe team will address this issue and community PRs are not requested.has: Pull RequestA PR has been created to address this issueresolution: fixedtype: conflict

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions