vitalets / angular-xeditable

Edit in place for AngularJS
http://vitalets.github.io/angular-xeditable
MIT License
1.91k stars 403 forks source link

Syntax error not tolerated by Node/Phantomjs/Karma #700

Closed vmandrychenko closed 6 years ago

vmandrychenko commented 7 years ago

Hello,

We ran into issue with the syntax while trying to run karma/jasmine/angularjs directive unit test that is testing a directive containing a snippet that is using angular-exeditable plugin.

The error we got was: "Syntax error, unrecognized expression: form[name='foobar'"

The fix for us was simple, it's adding another set of quotes on line 1322 in xeditable.js

Error line:

} else if (elem && typeof elem.parents === "function" && elem.parents().last().find('form[name='+attrs.eForm+']').length) { // form exists below or not exist at all: check document.forms

Fixed line:

} else if (elem && typeof elem.parents === "function" && elem.parents().last().find('form[name="'+attrs.eForm+'"]').length) { // form exists below or not exist at all: check document.forms

Note the double quotes around '+attrs.eForm+'.

The file that needs to be fixed is here: https://github.com/vitalets/angular-xeditable/blob/72a5c49d9309db1bdb18803a6e5837e51bc5a6b0/src/js/editable-element/directive.js, line 45

I wanted to submit a patch, but I failed to run unit tests locally on my mac following the instructions.

ckosloski commented 6 years ago

I will try to take a look at it this week.