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

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

@maxmart
Copy link
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 pushed a commit to IgorMinar/angular.js that referenced this issue Jun 7, 2012
Merging of interpolated class attribute from directive template with replace:true works

Closes angular#1006
@IgorMinar
Copy link
Contributor

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

IgorMinar pushed a commit to IgorMinar/angular.js that referenced this issue Jun 8, 2012
Merging of interpolated class attribute from directive template with replace:true works

Closes angular#1006
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants