Merging of class attribute in directives crashes if class attribute is not set on the original element #1006

Closed
maxmart opened this Issue Jun 1, 2012 · 1 comment

Projects

None yet

2 participants

@maxmart
Contributor
maxmart commented Jun 1, 2012

During the work of 1.0.0.rc2, the directive handling was probably rewritten. Support seems to have been added for merging class attributes when replacing an element: f49eaf8

But if the original element does not have a class attribute, attr[name] will be undefined and the $interpolate function will crash on length = text.length at line 4644 in angular-1.0.0rc10.js (I don't have the src-files in front of me)

The simplest solution is probably to change the if-clause in addAttrInterpolateDirective function from
if (name === 'class') {
to
if (name === 'class' && attr[name]) {

I'll probably request a pull for that in a few hours if I find the time :-)

@maxmart maxmart added a commit to maxmart/angular.js that referenced this issue Jun 6, 2012
@maxmart maxmart fix(compiler): Merging of interpolated class attribute from directive…
… template with replace:true works

Closes #1006
96b8d30
@maxmart maxmart added a commit to maxmart/angular.js that referenced this issue Jun 6, 2012
@maxmart maxmart fix(compiler): Merging of interpolated class attribute from directive…
… template with replace:true works

Closes #1006
a1abfca
@IgorMinar IgorMinar added a commit to IgorMinar/angular.js that referenced this issue Jun 7, 2012
@maxmart @IgorMinar maxmart + IgorMinar fix($compile): correctly merge class attr for replace directives
Merging of interpolated class attribute from directive template with replace:true works

Closes #1006
efd736b
@IgorMinar
Member

I took your PR and fixed it in a different way: #1025

@IgorMinar IgorMinar added a commit to IgorMinar/angular.js that referenced this issue Jun 8, 2012
@maxmart @IgorMinar maxmart + IgorMinar fix($compile): correctly merge class attr for replace directives
Merging of interpolated class attribute from directive template with replace:true works

Closes #1006
7cdfae6
@IgorMinar IgorMinar added a commit that closed this issue Jun 8, 2012
@maxmart @IgorMinar maxmart + IgorMinar fix($compile): correctly merge class attr for replace directives
Merging of interpolated class attribute from directive template with replace:true works

Closes #1006
fb99b53
@IgorMinar IgorMinar closed this in fb99b53 Jun 8, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment