-
Notifications
You must be signed in to change notification settings - Fork 27.1k
Upgraded components with ng-transclude error if there is no transcluded content #13271
Description
I'm submitting a ... (check one with "x")
[x] bug report
[ ] feature request
[ ] support request
Current behavior
When an upgraded ng1 component contains an ng-transclude directive, but the element is not supplied with content to transclude — e.g. it is empty, or should use fallback content — then the following error is thrown:
VM3034 angular.js:14110TypeError: Cannot read property '$destroy' of undefined
at ngTranscludeCloneAttachFn (https://unpkg.com/angular/angular.js:31320:29)
at attachChildNodes (https://unpkg.com/@angular/upgrade@2.3.0-rc.0/bundles/upgrade-static.umd.js:568:92)
at controllersBoundTransclude (https://unpkg.com/angular/angular.js:9542:20)
at Object.ngTranscludePostLink (https://unpkg.com/angular/angular.js:31306:9)
at eval (https://unpkg.com/angular/angular.js:1259:18)
at invokeLinkFn (https://unpkg.com/angular/angular.js:10095:9)
at nodeLinkFn (https://unpkg.com/angular/angular.js:9492:11)
at compositeLinkFn (https://unpkg.com/angular/angular.js:8757:13)
at MyUpgradedComponent.publicLinkFn [as linkFn] (https://unpkg.com/angular/angular.js:8637:30)
at MyUpgradedComponent.UpgradeComponent.ngOnInit (https://unpkg.com/@angular/upgrade@2.3.0-rc.0/bundles/upgrade-static.umd.js:569:18)
at Wrapper_MyUpgradedComponent.ngDoCheck (/AppModule/MyUpgradedComponent/wrapper.ngfactory.js:25:53)
at CompiledTemplate.proxyViewClass.View_App0.detectChangesInternal (/AppModule/App/component.ngfactory.js:27:33)
at CompiledTemplate.proxyViewClass.AppView.detectChanges (https://unpkg.com/@angular/core@2.3.0-rc.0/bundles/core.umd.js:12522:18)
at CompiledTemplate.proxyViewClass.DebugAppView.detectChanges (https://unpkg.com/@angular/core@2.3.0-rc.0/bundles/core.umd.js:12669:48)
at CompiledTemplate.proxyViewClass.View_App_Host0.detectChangesInternal (/AppModule/App/host.ngfactory.js:29:19) <ng-transclude class="ng-scope">
It seems the ng1 transclusion directive tries to destroy the transcluded scope if the transcluded content is empty, but UpgradeComponent doesn't actually supply a scope in this case.
Expected behavior
It should work without errors.
Minimal reproduction of the problem with instructions
https://plnkr.co/edit/iluIot4jXRbot4Rk3O9t?p=preview
What is the motivation / use case for changing the behavior?
Correctness, ease of upgrade.
Please tell us about your environment:
macOS Sierra
-
Angular version: 2.3.0-rc.0, 1.6.0-rc.2
-
Browser: all
-
Language: all