"Object #<Comment> has no method 'setAttribute'" for interpolated attribute of transcluded directive
When a directive is set to {transcluded:'element'} and it uses a interpolated attribute value, an exception is thrown with message: TypeError: Object #
It is tested against angular.min.js v1.2.0-rc1.
Here is sample directive test page:
<!doctype html>
<html ng-app="testApp">
<head>
<script type="text/javascript" src="http://code.angularjs.org/1.2.0rc1/angular.min.js"></script>
<script language='javascript'>
angular.module('testApp', [])
.directive('ngTest', function(){
return {
transclude: 'element',
scope: { ngTest:'@' }
}
});
</script>
</head>
<body>
<div ng-test="test{{var}}"></div>
</body>
</html>
Is there something wrong? thanks
Here is a plunk: http://plnkr.co/edit/HyU1WlnzXHdY0oHHGZFT?p=preview
Looks like a valid bug.
Getting something similar in 1.1.5 as well
This may have been fixed by e0c134b8bfa282379daec6a7137512d58f956443. @petebacondarwin can you check against master?
Not fixed by e0c134b.
The problem is really that the compiler is passing the the "transclude comment node" to the rather than the transcluded node through to the being delayed and applied to the attrInterpolationLinkFn at https://github.com/angular/angular.js/blob/master/src/ng/compile.js#L1329.
We need some way of deferring linking of this "interpolation directive" when its parent element contains a transclude:'element' directive.
This is the behavior that existed since 1.0.x. The issue is actually in the code. The directive that is doing element transclusion, needs to have a priority higher than attribute binding priority.
I fixed the example here: http://plnkr.co/edit/HyU1WlnzXHdY0oHHGZFT?p=preview
@IgorMinar - This link is to my original plunker so is still erroring.
Here is a fixed plunk: http://plnkr.co/edit/zjR1MloaxTV1iTR5ncTK?p=preview
attribute interpolation directives are currently at priority 100.
My solution for this was to change the priority of {{ }} (for both attributes and text nodes interpolation) to -1
I was going to send a PR, but with #4266 just submitted, I doubt that I should