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

Commit

Permalink
fix($compile): don't look for class directives in empty string
Browse files Browse the repository at this point in the history
if className is undefined or empty string, don't bother looking for directives in there
  • Loading branch information
IgorMinar committed Oct 30, 2012
1 parent 008a782 commit 54b3875
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/ng/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ function $CompileProvider($provide) {

// use class as directive
className = node.className;
if (isString(className)) {
if (isString(className) && className !== '') {
while (match = CLASS_DIRECTIVE_REGEXP.exec(className)) {
nName = directiveNormalize(match[2]);
if (addDirective(directives, nName, 'C', maxPriority)) {
Expand Down

1 comment on commit 54b3875

@ostrobongo
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I sugest a changing for that line:
from: if (isString(className) && className !== '') {
to: if (isString(className) & className !== '') {

The reason is: if className is null, the code (className !== ' ') might generate an exception. The operator "&" tests each condition separatelly.

Please sign in to comment.