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

Version 1.5.0:restrict 'A' on component() fails silently which might cause a lot of confusion #13966

Closed
radek-anuszewski opened this issue Feb 7, 2016 · 7 comments

Comments

@radek-anuszewski
Copy link

In early versions of AngularJS 1.5, it was possible to use restrict: 'A' for component() method, and I used it widely in my code. Breaking change came with 1.5.0-rc.1 quantum-fermentation (2016-01-15), where only restrict: 'E' became permitted, but I missed it (I think not only me) because I stayed with one of the previous 1.5.0 versions. Today I updated Angular's files to 1.5.0 final release and components with restrict: 'A' weren't visible and it took me a while to figure out that I have to replace attribute usages to element usages. Maybe, to avoid confusion, it should throw an Error when component() method meets restrict other than 'E'?
Thank you in advance for looking on this post.

Best regards,
Radek.

@petebacondarwin
Copy link
Contributor

Yes we talked about this recently... I think there might even be a PR somewhere.

@gkalpak
Copy link
Member

gkalpak commented Feb 8, 2016

The only relevant PR that I can think of is #13802 (which does not exactly cover this issue, but unsupported CDO properties in general).

@petebacondarwin, was #13802 what you had in mind ?

@petebacondarwin
Copy link
Contributor

Oh yes, @gkalpak that was it. Looks like I wasn't keen. :-/

@albatrosary
Copy link

Hello, everyone

I tried to implement the Component and Component Router of Angular1.5.It is an error in the difference of the value of the restrict for the Component and Component Router.

ComponentRouter is so as not to accept only 'A'.

(angular_1_router.js)

this.controller.$$routeParams = instruction.params;
this.controller.$$template = '<div ' + dashCase(componentName) + '></div>';
this.controller.$$router = this.router.childRouter(instruction.componentType);

But Angular1 Component is 'E'.

(angular/angular1.js)

      return {
        controller: controller,
        controllerAs: identifierForController(options.controller) || options.controllerAs || '$ctrl',
        template: makeInjectable(template),
        templateUrl: makeInjectable(options.templateUrl),
        transclude: options.transclude,
        scope: {},
        bindToController: options.bindings || {},
        restrict: 'E',
        require: options.require
      };

When I say that either, I think that is good to the 'E'.

Thank you.

@gkalpak
Copy link
Member

gkalpak commented Feb 9, 2016

@albatrosary, this has been fixed with angular/angular#6796 (the router will create elements, instead of divs). The fix will be included in the next release of the router.

@albatrosary
Copy link

@gkalpak, Great! ,Thank you.

@Narretz
Copy link
Contributor

Narretz commented Feb 15, 2016

Since not many people will be affected by the BC from beta to 1.5.0, we'll not gonna log / throw etc. here. Maybe we can do the validation inside the ngHint project, but that's also very low priority: angular/angular-hint#118

@Narretz Narretz closed this as completed Feb 15, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants