Skip to content

Commit 5908448

Browse files
author
Zdenko Vujasinovic
committed
small fix for CSX attribute validation
1 parent 9da14a2 commit 5908448

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

lib/coffeescript/nodes.js

+3-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/nodes.coffee

+6-2
Original file line numberDiff line numberDiff line change
@@ -884,9 +884,13 @@ exports.Call = class Call extends Base
884884
for obj in attributes.base.objects
885885
attr = obj.base
886886
attrProps = attr?.properties or []
887+
console.log attr, attrProps
887888
# Catch invalid CSX attributes: <div {a:"b", props} {props} "value" />
888-
if not (attr instanceof Obj or attr instanceof IdentifierLiteral) or (attr instanceof Obj and not attr.generated and (attrProps > 1 or not (attrProps[0] instanceof Splat)))
889-
obj.error 'Unexpected token. Allowed CSX attributes are: id="val", src={source} or {props...}'
889+
if not (attr instanceof Obj or attr instanceof IdentifierLiteral) or (attr instanceof Obj and not attr.generated and (attrProps.length > 1 or not (attrProps[0] instanceof Splat)))
890+
obj.error """
891+
Unexpected token. Allowed CSX attributes are: id="val", src={source}, {props...} or attribute.
892+
Example: <div id="val" src={getTheSource()} {props...} checked>hellow world</div>.
893+
"""
890894
obj.base.csx = yes if obj.base instanceof Obj
891895
fragments.push @makeCode ' '
892896
fragments.push obj.compileToFragments(o, LEVEL_PAREN)...

0 commit comments

Comments
 (0)