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