Skip to content

Commit

Permalink
feat: lang="html" should be removed from <template>
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterAlfredLee committed Jul 1, 2021
1 parent 5dda4cb commit 03fffd1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/ast-parse/transformations/addJsxTransformation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Context } from './index'
import { stringifyDescriptor } from '@originjs/vue-sfc-ast-parser'

export const transformAST:ASTTransformation = (context: Context) => {
if (context.scriptAST.findJSXElements().length === 0) {
if (!context.scriptAST || context.scriptAST.findJSXElements().length === 0) {
return null;
}

Expand Down
3 changes: 2 additions & 1 deletion src/ast-parse/transformations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ export const transformationMap: {
needReparse: boolean
}
} = {
addJsxTransformation: require('./addJsxTransformation')
addJsxTransformation: require('./addJsxTransformation'),
removeHtmlLangInTemplateTransformation: require('./removeHtmlLangInTemplateTransformation')
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import type { ASTTransformation } from './index'
import { Context } from './index'
import { stringifyDescriptor } from '@originjs/vue-sfc-ast-parser'

export const transformAST:ASTTransformation = (context: Context) => {
if (!context.descriptor.template || !context.descriptor.template.attrs!.lang) {
return null;
}

if (context.descriptor.template.attrs.lang === 'html') {
delete context.descriptor.template.attrs.lang
}
return stringifyDescriptor(context.descriptor);
}

export const needReparse : boolean = false

0 comments on commit 03fffd1

Please sign in to comment.