2020-02-04 21:03:16 -05:00
|
|
|
import {
|
|
|
|
DirectiveTransform,
|
|
|
|
DOMErrorCodes,
|
|
|
|
createObjectProperty,
|
|
|
|
createSimpleExpression,
|
|
|
|
createConditionalExpression,
|
2020-02-05 14:23:03 -05:00
|
|
|
createObjectExpression,
|
|
|
|
createDOMCompilerError
|
2020-02-04 21:03:16 -05:00
|
|
|
} from '@vue/compiler-dom'
|
2020-02-04 12:20:51 -05:00
|
|
|
|
2020-02-04 16:47:12 -05:00
|
|
|
export const ssrTransformShow: DirectiveTransform = (dir, node, context) => {
|
2020-02-04 21:03:16 -05:00
|
|
|
if (!dir.exp) {
|
2020-02-05 14:23:03 -05:00
|
|
|
context.onError(
|
|
|
|
createDOMCompilerError(DOMErrorCodes.X_V_SHOW_NO_EXPRESSION)
|
|
|
|
)
|
2020-02-04 21:03:16 -05:00
|
|
|
}
|
2020-02-04 12:20:51 -05:00
|
|
|
return {
|
2020-02-04 21:03:16 -05:00
|
|
|
props: [
|
|
|
|
createObjectProperty(
|
2020-02-06 12:05:53 -05:00
|
|
|
`style`,
|
2020-02-04 21:03:16 -05:00
|
|
|
createConditionalExpression(
|
|
|
|
dir.exp!,
|
|
|
|
createSimpleExpression(`null`, false),
|
|
|
|
createObjectExpression([
|
|
|
|
createObjectProperty(
|
2020-02-06 12:05:53 -05:00
|
|
|
`display`,
|
2020-02-04 21:03:16 -05:00
|
|
|
createSimpleExpression(`none`, true)
|
|
|
|
)
|
|
|
|
]),
|
|
|
|
false /* no newline */
|
|
|
|
)
|
|
|
|
)
|
|
|
|
]
|
2020-02-04 12:20:51 -05:00
|
|
|
}
|
|
|
|
}
|