-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Glimmer 2] invalid inlineclassNameBindings
inlink-to
yields an exception
#13955
Comments
We should issue a helpful assertion. Ideally in both engines. |
Thanks, I can take this on |
TL;DR: it looks like we're generating an incorrect spec For the template: {{foo-bar classNameBindings="someInitiallyTrueProperty isBig:big:small"}} Here's the processed AST (with loc info removed): {
"type": "Program",
"body": [
{
"type": "MustacheStatement",
"path": {
"type": "PathExpression",
"data": false,
"original": "foo-bar",
"parts": [
"foo-bar"
]
},
"params": [],
"hash": {
"type": "Hash",
"pairs": [
{
"type": "HashPair",
"key": "class",
"value": {
"type": "SubExpression",
"path": {
"type": "PathExpression",
"original": "concat",
"parts": [
"concat"
],
"data": false
},
"params": [
{
"type": "SubExpression",
"path": {
"type": "PathExpression",
"original": "if",
"parts": [
"if"
],
"data": false
},
"params": [
{
"type": "PathExpression",
"original": "someInitiallyTrueProperty",
"parts": [
"someInitiallyTrueProperty"
],
"data": false
},
{
"type": "SubExpression",
"path": {
"type": "StringLiteral",
"value": "-normalize-class",
"original": "-normalize-class"
},
"params": [
{
"type": "StringLiteral",
"value": "someInitiallyTrueProperty",
"original": "someInitiallyTrueProperty"
},
{
"type": "PathExpression",
"original": "someInitiallyTrueProperty",
"parts": [
"someInitiallyTrueProperty"
],
"data": false
}
],
"hash": {
"type": "Hash",
"pairs": []
}
}
],
"hash": {
"type": "Hash",
"pairs": []
}
},
{
"type": "StringLiteral",
"value": " ",
"original": " "
},
{
"type": "SubExpression",
"path": {
"type": "PathExpression",
"original": "if",
"parts": [
"if"
],
"data": false
},
"params": [
{
"type": "PathExpression",
"original": "isBig",
"parts": [
"isBig"
],
"data": false
},
{
"type": "StringLiteral",
"value": "big",
"original": "big"
},
{
"type": "StringLiteral",
"value": "small",
"original": "small"
}
],
"hash": {
"type": "Hash",
"pairs": []
}
},
{
"type": "StringLiteral",
"value": " ",
"original": " "
}
],
"hash": {
"type": "Hash",
"pairs": []
}
}
}
]
},
"escaped": true
}
],
"blockParams": []
} This then produces the following spec which looks incorrect (there's nothing about {
"statements": [
[
"append",
[
"helper",
[
"foo-bar"
],
null,
{
"class": [
"helper",
[
"concat"
],
[
[
"helper",
[
"if"
],
[
[
"get",
[
"someInitiallyTrueProperty"
]
],
[
"helper",
null,
[
"someInitiallyTrueProperty",
[
"get",
[
"someInitiallyTrueProperty"
]
]
],
null
]
],
null
],
" ",
[
"helper",
[
"if"
],
[
[
"get",
[
"isBig"
]
],
"big",
"small"
],
null
],
" "
],
null
]
}
],
false
]
],
"locals": [],
"named": [],
"yields": [],
"blocks": [],
"meta": {
"moduleName": "-top-level"
}
} Here are the equivalent htmlbars statements: statements: [
["inline","foo-bar",[],["class",["subexpr","concat",[["subexpr","if",[["get","someInitiallyTrueProperty",[],0,0,0,0],["subexpr","-normalize-class",["someInitiallyTrueProperty",["get","someInitiallyTrueProperty",[],0,0,0,0]],[],[],0,0]],[],[],0,0]," ",["subexpr","if",[["get","isBig",[],0,0,0,0],"big","small"],[],[],0,0]," "],[],[],0,0]],["loc",[null,[1,0],[1,73]]],0,0]
] |
@chadhietala perhaps you might be able to add some insight here? |
Let me take a look 🙇 |
This was fixed in #14028. |
The invalid
classNameBindings
below behaves inconsistently in htmlbars and glimmer (see https://github.com/GavinJoyce/glammer/blob/master/app/templates/issue1.hbs).htmlbars:
no warning, the follow is rendered:
glimmer:
an exception is thrown when rendering:
Cannot read property '0' of null (in hasHelper)
Some questions:
The text was updated successfully, but these errors were encountered: