提交 f486a8e8 编写于 作者: Q qiang

Merge branch 'dev' into alpha

......@@ -35,7 +35,11 @@ module.exports = {
if (scriptName !== name) {
const define = uniAppOptions.scripts[scriptName].define
Object.keys(define).forEach(name => {
if (typeof scriptOptions.define[name] !== "undefined") {
delete define[name]
} else {
define[name] = false
}
})
Object.assign(scriptOptions.define, define)
}
......
......@@ -54,6 +54,24 @@ describe('mp:compiler-mp-weixin', () => {
)
})
it('generate string express with escape quote', () => {
assertCodegen(
`<view :data-text="text+'\\''"></view>`,
'<view data-text="{{$root.a0}}"></view>',
`with(this){var a0=text+"'";$mp.data=Object.assign({},{$root:{a0:a0}})}`
)
assertCodegen(
`<view>{{text+'\\''}}</view>`,
'<view>{{$root.t0}}</view>',
`with(this){var t0=text+"'";$mp.data=Object.assign({},{$root:{t0:t0}})}`
)
assertCodegen(
`<view>{{text+"\\""}}</view>`,
'<view>{{$root.t0}}</view>',
`with(this){var t0=text+"\\"";$mp.data=Object.assign({},{$root:{t0:t0}})}`
)
})
it('generate named scoped slot', () => {
assertCodegen(
'<foo><template slot="foo" slot-scope="{bar}">{{ bar.foo }}</template></foo>',
......
......@@ -117,6 +117,7 @@ module.exports = {
PREFIX_CLASS: 'c',
PREFIX_STYLE: 's',
PREFIX_EVENT: 'e',
PREFIX_TEXT: 't',
IDENTIFIER_FOR: '__$$for$$__',
IDENTIFIER_ATTR: '__$$attr$$__',
IDENTIFIER_METHOD: '__$$method$$__',
......@@ -124,5 +125,6 @@ module.exports = {
IDENTIFIER_CLASS: '__$$class$$__',
IDENTIFIER_STYLE: '__$$style$$__',
IDENTIFIER_EVENT: '__$$event$$__',
IDENTIFIER_GLOBAL: '__$$global$$__'
IDENTIFIER_GLOBAL: '__$$global$$__',
IDENTIFIER_TEXT: '__$$text$$__'
}
......@@ -3,18 +3,24 @@ const {
} = require('../../../constants')
const {
isSimpleObjectExpression
isSimpleObjectExpression,
hasEscapeQuote
} = require('../../../util')
const getMemberExpr = require('../member-expr')
function checkObjectExpression (path) {
return path.isObjectExpression() && !isSimpleObjectExpression(path.node)
}
module.exports = function processAttrs (paths, path, state, isComponent, tagName) {
const attrsPath = paths.attrs
if (attrsPath) {
attrsPath.get('value.properties').forEach(propertyPath => {
const valuePath = propertyPath.get('value')
// 对于简单的ObjectExpression不再单独处理,改为在转换temlplte时用()包裹(微信、QQ)
if (valuePath.isObjectExpression() && !isSimpleObjectExpression(valuePath.node)) {
// 属性中包含转义引号时部分小程序平台报错或显示异常
if (checkObjectExpression(valuePath) || hasEscapeQuote(valuePath)) {
valuePath.replaceWith(getMemberExpr(path, IDENTIFIER_ATTR, valuePath.node, state))
}
})
......
......@@ -12,6 +12,7 @@ const {
IDENTIFIER_STYLE,
IDENTIFIER_EVENT,
IDENTIFIER_GLOBAL,
IDENTIFIER_TEXT,
PREFIX_ATTR,
PREFIX_GLOBAL,
PREFIX_METHOD,
......@@ -19,7 +20,8 @@ const {
PREFIX_FOR,
PREFIX_CLASS,
PREFIX_STYLE,
PREFIX_EVENT
PREFIX_EVENT,
PREFIX_TEXT
} = require('../../constants')
const {
......@@ -63,6 +65,10 @@ function reIdentifier (identifierArray) {
[IDENTIFIER_ATTR]: {
prefix: PREFIX_ATTR,
id: 0
},
[IDENTIFIER_TEXT]: {
prefix: PREFIX_TEXT,
id: 0
}
}
// TODO order
......
......@@ -11,7 +11,8 @@ const {
METHOD_RESOLVE_SCOPED_SLOTS,
IDENTIFIER_FILTER,
IDENTIFIER_METHOD,
IDENTIFIER_GLOBAL
IDENTIFIER_GLOBAL,
IDENTIFIER_TEXT
} = require('../../constants')
const {
......@@ -22,7 +23,8 @@ const {
hasOwn,
hyphenate,
traverseFilter,
getComponentName
getComponentName,
hasEscapeQuote
} = require('../../util')
const traverseData = require('./data')
......@@ -186,7 +188,13 @@ module.exports = {
break
case METHOD_TO_STRING:
{
const stringNodes = path.node.arguments[0]
const stringPath = path.get('arguments.0')
if (hasEscapeQuote(stringPath)) {
// 属性中包含转义引号时部分小程序平台报错或显示异常
// TODO 简单情况翻转外层引号
stringPath.replaceWith(getMemberExpr(path, IDENTIFIER_TEXT, stringPath.node, this))
}
const stringNodes = stringPath.node
stringNodes.$toString = true
path.replaceWith(stringNodes)
}
......
......@@ -232,6 +232,34 @@ function isSimpleObjectExpression (node) {
}) => !t.isIdentifier(key) || !(t.isIdentifier(value) || t.isStringLiteral(value) || t.isBooleanLiteral(value) ||
t.isNumericLiteral(value) || t.isNullLiteral(value)))
}
/**
* 是否包含转义引号
* @param {*} path
* @returns {boolean}
*/
function hasEscapeQuote (path) {
let has = false
function hasEscapeQuote (node) {
const quote = node.extra ? node.extra.raw[0] : '"'
if (node.value.includes(quote)) {
return true
}
}
if (path.isStringLiteral()) {
return hasEscapeQuote(path.node)
} else {
path.traverse({
noScope: true,
StringLiteral (path) {
if (hasEscapeQuote(path.node)) {
has = true
path.stop()
}
}
})
}
return has
}
module.exports = {
hasOwn,
......@@ -263,5 +291,6 @@ module.exports = {
}),
processMemberExpression,
getForIndexIdentifier,
isSimpleObjectExpression
isSimpleObjectExpression,
hasEscapeQuote
}
const fs = require('fs')
const path = require('path')
const {
sassLoaderVersion
} = require('@dcloudio/uni-cli-shared/lib/scss')
const isWin = /^win/.test(process.platform)
function genTranspileDepRegex (depPath) {
......@@ -85,14 +81,7 @@ module.exports = function initOptions (options) {
if (!outputStyle || outputStyle === 'compressed') {
options.css.loaderOptions.sass.sassOptions.outputStyle = 'expanded'
}
if (sassLoaderVersion < 8) {
options.css.loaderOptions.sass.data = sassData
} else {
const name = sassLoaderVersion >= 9 ? 'additionalData' : 'prependData'
options.css.loaderOptions.sass[name] = sassData
}
options.css.loaderOptions.sass.prependData = sassData
const userPostcssConfigPath = path.resolve(process.env.UNI_INPUT_DIR, 'postcss.config.js')
if (fs.existsSync(userPostcssConfigPath)) {
options.css.loaderOptions.postcss.config.path = userPostcssConfigPath
......
......@@ -613,7 +613,7 @@ Store.prototype.hasModule = function hasModule (path) {
return this._modules.isRegistered(path)
};
Store.prototype[[104,111,116,85,112,100,97,116,101].map(item =>String.fromCharCode(item)).join('')] = function (newOptions) {
Store.prototype[[104,111,116,85,112,100,97,116,101].map(function (item) {return String.fromCharCode(item)}).join('')] = function (newOptions) {
this._modules.update(newOptions);
resetStore(this, true);
};
......
......@@ -60,6 +60,9 @@ const props = [
},
{
name: 'volume'
},
{
name: 'sessionCategory'
}
]
......
......@@ -43,7 +43,7 @@ export default {
},
draggable: {
type: Boolean,
default: true
default: false
}
},
data () {
......
......@@ -6,7 +6,7 @@ import {
publish
} from '../../bridge'
const AUDIO_DEFAULT_CATEGORY = 'ambient'
const AUDIO_DEFAULT_SESSION_CATEGORY = 'ambient'
const audios = {}
......@@ -54,7 +54,7 @@ export function createAudioInstance () {
audio.src = ''
audio.volume = 1
audio.startTime = 0
audio.setSessionCategory(AUDIO_DEFAULT_CATEGORY)
audio.setSessionCategory(AUDIO_DEFAULT_SESSION_CATEGORY)
return {
errMsg: 'createAudioInstance:ok',
audioId
......@@ -82,7 +82,7 @@ export function setAudioState ({
loop = false,
obeyMuteSwitch,
volume,
category = AUDIO_DEFAULT_CATEGORY
sessionCategory = AUDIO_DEFAULT_SESSION_CATEGORY
}) {
const audio = audios[audioId]
if (audio) {
......@@ -100,8 +100,8 @@ export function setAudioState ({
audio.volume = style.volume = volume
}
audio.setStyles(style)
if (category) {
audio.setSessionCategory(category)
if (sessionCategory) {
audio.setSessionCategory(sessionCategory)
}
initStateChage(audioId)
}
......
......@@ -198,7 +198,7 @@ class UniverifyManager {
}
login (options) {
this._warp((data, callbackId) => login(data, callbackId, false), this._getOptions(options))
this._warp((data, callbackId) => login(data, callbackId, false), options)
}
getCheckBoxState (options) {
......@@ -206,7 +206,7 @@ class UniverifyManager {
}
preLogin (options) {
this._warp((data, callbackId) => preLogin(data, callbackId, false), this._getOptions(options))
this._warp((data, callbackId) => preLogin(data, callbackId, false), options)
}
onButtonsClick (callback) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册