diff --git a/lib/tally.coffee b/lib/tally.coffee index 62b45ddec66447c90492ffca4bedf14dfe50a572..0ce07460068e6c44bf4ed58ccfa122f013262386 100644 --- a/lib/tally.coffee +++ b/lib/tally.coffee @@ -361,8 +361,6 @@ tally = (root, obj) -> # Ignore empty spaces attr = attr.trim() - # console.log('Attr: >' + attr + '<') - if attr == '' throw new Error('empty data-tally-attribute definition on element: ' + node.outerHTML) @@ -379,7 +377,7 @@ tally = (root, obj) -> throw new Error('missing attribute name for attribute ' + i) if not attr[1] - throw new Error('missing attribute value for attribute ' + i) + throw new Error('missing attribute value for attribute ' + i + ' (\'' + name + '\')') value = resolve(obj, attr[1]) value = "" if value is `undefined` diff --git a/lib/tally.js b/lib/tally.js index d6fc2a85db02bd78f9e4ee15a7942b3abae52462..ef0c8a4672c062dbccb559a4fce4dcd0a364c631 100644 --- a/lib/tally.js +++ b/lib/tally.js @@ -316,7 +316,7 @@ Forked from Distal by mocking@gmail.com (https://code.google.com/p/distal/) throw new Error('missing attribute name for attribute ' + i); } if (!attr[1]) { - throw new Error('missing attribute value for attribute ' + i); + throw new Error('missing attribute value for attribute ' + i + ' (\'' + name + '\')'); } value = resolve(obj, attr[1]); if (value === undefined) { diff --git a/test/render.coffee b/test/render.coffee index be964c4fe2502c2bf6582f3492a6d554a21432ee..b02413775f6efead5f0c82e94292202fc6ba4d61 100644 --- a/test/render.coffee +++ b/test/render.coffee @@ -59,6 +59,10 @@ describe 'Tally', -> # # Error checking tests for data-tally-attribute. # + it 'should fail if an attribute has a missing value', -> + (-> + tally('

', {theURL: 'http://aralbalkan.com'})).should.throw('missing attribute value for attribute 0 (\'href\')') + it 'should not fail if a single attribute ends with a semi-colon', -> (-> tally('

', {theURL: 'http://aralbalkan.com'})).should.not.throw() @@ -69,11 +73,11 @@ describe 'Tally', -> it 'should fail if an attribute just has a semi‐colon in it', -> (-> - tally('

', {})).should.throw('missing attribute value for attribute 0') + tally('

', {})).should.throw('missing attribute value for attribute 0 (\';\')') it 'should fail if an attribute just multiple semi‐colons in it', -> (-> - tally('

', {})).should.throw('missing attribute value for attribute 0') + tally('

', {})).should.throw('missing attribute value for attribute 0 (\';;\')') it 'should fail if an attribute just multiple semi‐colons with spaces between them in it', -> (->