提交 535a3610 编写于 作者: fxy060608's avatar fxy060608

feat(cli): add isUnaryTag #625

上级 caeb0673
...@@ -2,6 +2,10 @@ const { ...@@ -2,6 +2,10 @@ const {
tags tags
} = require('@dcloudio/uni-cli-shared') } = require('@dcloudio/uni-cli-shared')
const {
isUnaryTag
} = require('../util')
const simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/ const simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/
function processEvent (expr, filterModules) { function processEvent (expr, filterModules) {
...@@ -41,6 +45,7 @@ function addTag (tag) { ...@@ -41,6 +45,7 @@ function addTag (tag) {
} }
module.exports = { module.exports = {
isUnaryTag,
preserveWhitespace: false, preserveWhitespace: false,
modules: [require('../format-text'), { modules: [require('../format-text'), {
preTransformNode (el, { preTransformNode (el, {
......
...@@ -13,6 +13,10 @@ const { ...@@ -13,6 +13,10 @@ const {
getPlatformCssnano getPlatformCssnano
} = require('@dcloudio/uni-cli-shared') } = require('@dcloudio/uni-cli-shared')
const {
isUnaryTag
} = require('./util')
function createUniMPPlugin () { function createUniMPPlugin () {
if (process.env.UNI_USING_COMPONENTS) { if (process.env.UNI_USING_COMPONENTS) {
const WebpackUniMPPlugin = require('@dcloudio/webpack-uni-mp-loader/lib/plugin/index-new') const WebpackUniMPPlugin = require('@dcloudio/webpack-uni-mp-loader/lib/plugin/index-new')
...@@ -154,6 +158,7 @@ module.exports = { ...@@ -154,6 +158,7 @@ module.exports = {
.tap(options => Object.assign(options, { .tap(options => Object.assign(options, {
compiler: getPlatformCompiler(), compiler: getPlatformCompiler(),
compilerOptions: process.env.UNI_USING_COMPONENTS ? { compilerOptions: process.env.UNI_USING_COMPONENTS ? {
isUnaryTag,
preserveWhitespace: false preserveWhitespace: false
} : require('./mp-compiler-options'), } : require('./mp-compiler-options'),
cacheDirectory: false, cacheDirectory: false,
......
function makeMap (str, expectsLowerCase) {
const map = Object.create(null)
const list = str.split(',')
for (let i = 0; i < list.length; i++) {
map[list[i]] = true
}
return expectsLowerCase
? val => map[val.toLowerCase()]
: val => map[val]
}
module.exports = {
isUnaryTag: makeMap(
'image,area,base,br,col,embed,frame,hr,img,input,isindex,keygen,' +
'link,meta,param,source,track,wbr'
)
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册