New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Comments

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 added a commit to maxmart/angular.js that referenced this issue Jun 6, 2012

maxmart added a commit to maxmart/angular.js that referenced this issue Jun 6, 2012

IgorMinar added a commit to IgorMinar/angular.js that referenced this issue Jun 7, 2012

fix($compile): correctly merge class attr for replace directives
Merging of interpolated class attribute from directive template with replace:true works

Closes #1006
@IgorMinar

This comment has been minimized.

Show comment
Hide comment
@IgorMinar

IgorMinar Jun 7, 2012

Member

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

Member

IgorMinar commented Jun 7, 2012

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

IgorMinar added a commit to IgorMinar/angular.js that referenced this issue Jun 8, 2012

fix($compile): correctly merge class attr for replace directives
Merging of interpolated class attribute from directive template with replace:true works

Closes #1006

@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