Skip to content

Commit

Permalink
fix(mp): 修复virtualHostId处理错误、减小编译产物体积
Browse files Browse the repository at this point in the history
  • Loading branch information
Wangyaqi committed Jan 2, 2025
1 parent 20ea4f9 commit 8a3403f
Show file tree
Hide file tree
Showing 7 changed files with 129 additions and 132 deletions.
100 changes: 50 additions & 50 deletions packages/uni-mp-compiler/__tests__/mergeVirtualHostAttributes.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,25 @@ describe('complier: options with mergeVirtualHostAttributes', () => {
test('root node with mergeVirtualHostAttributes', () => {
assert(
`<image/>`,
`<image class="{{[virtualHostClass]}}" style="{{virtualHostStyle}}" hidden="{{virtualHostHidden}}" id="{{virtualHostId}}"/>`,
`<image class=\"{{[virtualHostClass]}}\" style=\"{{virtualHostStyle}}\" hidden=\"{{virtualHostHidden}}\" id=\"{{a}}\"/>`,
`(_ctx, _cache) => {
return {}
return { a: _gei(_ctx, '') }
}`,
options
)
assert(
`<view><image/></view>`,
`<view class="{{[virtualHostClass]}}" style="{{virtualHostStyle}}" hidden="{{virtualHostHidden}}" id="{{virtualHostId}}"><image/></view>`,
`<view class=\"{{[virtualHostClass]}}\" style=\"{{virtualHostStyle}}\" hidden=\"{{virtualHostHidden}}\" id=\"{{a}}\"><image/></view>`,
`(_ctx, _cache) => {
return {}
return { a: _gei(_ctx, '') }
}`,
options
)
assert(
`<view ref="page"><image ref="img" /></view>`,
`<view ref=\"page\" id=\"{{c}}\" style=\"{{$eS[c] + ';' + virtualHostStyle}}\" class=\"{{[virtualHostClass]}}\" hidden=\"{{virtualHostHidden}}\"><image ref=\"img\" id=\"r0-2a9ec0b0\" style=\"{{$eS[a]}}\"/></view>`,
`(_ctx, _cache) => {
const __returned__ = { a: _sei('r0-2a9ec0b0', 'image', 'img'), b: _s(_ses('r0-2a9ec0b0')), c: _sei(_ctx.virtualHostId !== '' ? _ctx.virtualHostId : 'r1-2a9ec0b0', 'view', 'page'), d: _s(_ses(_ctx.virtualHostId !== '' ? _ctx.virtualHostId : 'r1-2a9ec0b0')) }
const __returned__ = { a: _sei('r0-2a9ec0b0', 'image', 'img'), b: _s(_ses('r0-2a9ec0b0')), c: _sei(_gei(_ctx, '', 'r1-2a9ec0b0'), 'view', 'page'), d: _s(_ses(_gei(_ctx, '', 'r1-2a9ec0b0'))) }
return __returned__
}`,
optionsX
Expand All @@ -45,127 +45,127 @@ describe('complier: options with mergeVirtualHostAttributes', () => {
test('root node style with mergeVirtualHostAttributes', () => {
assert(
`<image style="width:100%"/>`,
`<image class="{{[virtualHostClass]}}" style="{{'width:100%' + ';' + virtualHostStyle}}" hidden="{{virtualHostHidden}}" id="{{virtualHostId}}"/>`,
`<image class=\"{{[virtualHostClass]}}\" style=\"{{'width:100%' + ';' + virtualHostStyle}}\" hidden=\"{{virtualHostHidden}}\" id=\"{{a}}\"/>`,
`(_ctx, _cache) => {
return {}
return { a: _gei(_ctx, '') }
}`,
options
)
assert(
`<image :style="style"/>`,
`<image style="{{a + ';' + virtualHostStyle}}" class="{{[virtualHostClass]}}" hidden="{{virtualHostHidden}}" id="{{virtualHostId}}"/>`,
`<image style="{{a + ';' + virtualHostStyle}}" class="{{[virtualHostClass]}}" hidden="{{virtualHostHidden}}" id="{{b}}"/>`,
`(_ctx, _cache) => {
return { a: _s(_ctx.style) }
return { a: _s(_ctx.style), b: _gei(_ctx, '') }
}`,
options
)
assert(
`<image style="width:100%" :style="style"/>`,
`<image style="{{'width:100%' + ';' + a + ';' + virtualHostStyle}}" class="{{[virtualHostClass]}}" hidden="{{virtualHostHidden}}" id="{{virtualHostId}}"/>`,
`<image style="{{'width:100%' + ';' + a + ';' + virtualHostStyle}}" class="{{[virtualHostClass]}}" hidden="{{virtualHostHidden}}" id="{{b}}"/>`,
`(_ctx, _cache) => {
return { a: _s(_ctx.style) }
return { a: _s(_ctx.style), b: _gei(_ctx, '') }
}`,
options
)
})
test('root node class with mergeVirtualHostAttributes', () => {
assert(
`<image class="class1"/>`,
`<image class="{{['class1', virtualHostClass]}}" style="{{virtualHostStyle}}" hidden="{{virtualHostHidden}}" id="{{virtualHostId}}"/>`,
`<image class=\"{{['class1', virtualHostClass]}}\" style=\"{{virtualHostStyle}}\" hidden=\"{{virtualHostHidden}}\" id=\"{{a}}\"/>`,
`(_ctx, _cache) => {
return {}
return { a: _gei(_ctx, '') }
}`,
options
)
assert(
`<image :class="class1"/>`,
`<image class="{{[a, virtualHostClass]}}" style="{{virtualHostStyle}}" hidden="{{virtualHostHidden}}" id="{{virtualHostId}}"/>`,
`<image class="{{[a, virtualHostClass]}}" style="{{virtualHostStyle}}" hidden="{{virtualHostHidden}}" id="{{b}}"/>`,
`(_ctx, _cache) => {
return { a: _n(_ctx.class1) }
return { a: _n(_ctx.class1), b: _gei(_ctx, '') }
}`,
options
)
assert(
`<image class="class1" :class="class1"/>`,
`<image class="{{['class1', a, virtualHostClass]}}" style="{{virtualHostStyle}}" hidden="{{virtualHostHidden}}" id="{{virtualHostId}}"/>`,
`<image class="{{['class1', a, virtualHostClass]}}" style="{{virtualHostStyle}}" hidden="{{virtualHostHidden}}" id="{{b}}"/>`,
`(_ctx, _cache) => {
return { a: _n(_ctx.class1) }
return { a: _n(_ctx.class1), b: _gei(_ctx, '') }
}`,
options
)
})
test('root node hidden with mergeVirtualHostAttributes', () => {
assert(
`<image :hidden="hidden"/>`,
`<image hidden="{{virtualHostHidden !== '' ? virtualHostHidden : a}}" class="{{[virtualHostClass]}}" style="{{virtualHostStyle}}" id="{{virtualHostId}}"/>`,
`<image hidden=\"{{virtualHostHidden !== '' ? virtualHostHidden : a}}\" class=\"{{[virtualHostClass]}}\" style=\"{{virtualHostStyle}}\" id=\"{{b}}\"/>`,
`(_ctx, _cache) => {
return { a: _ctx.hidden }
return { a: _ctx.hidden, b: _gei(_ctx, '') }
}`,
options
)
assert(
`<image :hidden="!show"/>`,
`<image hidden="{{virtualHostHidden !== '' ? virtualHostHidden : a}}" class="{{[virtualHostClass]}}" style="{{virtualHostStyle}}" id="{{virtualHostId}}"/>`,
`<image hidden=\"{{virtualHostHidden !== '' ? virtualHostHidden : a}}\" class=\"{{[virtualHostClass]}}\" style=\"{{virtualHostStyle}}\" id=\"{{b}}\"/>`,
`(_ctx, _cache) => {
return { a: !_ctx.show }
return { a: !_ctx.show, b: _gei(_ctx, '') }
}`,
options
)
assert(
`<image :hidden="false"/>`,
`<image hidden="{{virtualHostHidden !== '' ? virtualHostHidden : false}}" class="{{[virtualHostClass]}}" style="{{virtualHostStyle}}" id="{{virtualHostId}}"/>`,
`<image hidden=\"{{virtualHostHidden !== '' ? virtualHostHidden : false}}\" class=\"{{[virtualHostClass]}}\" style=\"{{virtualHostStyle}}\" id=\"{{a}}\"/>`,
`(_ctx, _cache) => {
return {}
return { a: _gei(_ctx, '') }
}`,
options
)
assert(
`<image hidden/>`,
`<image class="{{[virtualHostClass]}}" style="{{virtualHostStyle}}" hidden="{{virtualHostHidden !== '' ? virtualHostHidden : true}}" id="{{virtualHostId}}"/>`,
`<image class="{{[virtualHostClass]}}" style="{{virtualHostStyle}}" hidden="{{virtualHostHidden !== '' ? virtualHostHidden : true}}" id="{{a}}"/>`,
`(_ctx, _cache) => {
return {}
return { a: _gei(_ctx, '') }
}`,
options
)
assert(
`<image v-show="show"/>`,
`<image class="{{[virtualHostClass]}}" style="{{virtualHostStyle}}" hidden="{{virtualHostHidden !== '' ? virtualHostHidden : !a}}" id="{{virtualHostId}}"/>`,
`<image class=\"{{[virtualHostClass]}}\" style=\"{{virtualHostStyle}}\" hidden=\"{{virtualHostHidden !== '' ? virtualHostHidden : !a}}\" id=\"{{b}}\"/>`,
`(_ctx, _cache) => {
return { a: _ctx.show }
return { a: _ctx.show, b: _gei(_ctx, '') }
}`,
options
)
})
test('root node id with mergeVirtualHostAttributes', () => {
assert(
`<image id="id1"/>`,
`<image class=\"{{[virtualHostClass]}}\" style=\"{{virtualHostStyle}}\" hidden=\"{{virtualHostHidden}}\" id=\"{{a || virtualHostId === '' ? 'id1' : virtualHostId}}\"/>`,
`<image class=\"{{[virtualHostClass]}}\" style=\"{{virtualHostStyle}}\" hidden=\"{{virtualHostHidden}}\" id=\"{{a}}\"/>`,
`(_ctx, _cache) => {
return { a: 'id' in _ctx.$.type.props }
return { a: _gei(_ctx, 'id1') }
}`,
options
)
assert(
`<image :id="id1"/>`,
`<image id=\"{{b || virtualHostId === '' ? a : virtualHostId}}\" class=\"{{[virtualHostClass]}}\" style=\"{{virtualHostStyle}}\" hidden=\"{{virtualHostHidden}}\"/>`,
`<image id=\"{{a}}\" class=\"{{[virtualHostClass]}}\" style=\"{{virtualHostStyle}}\" hidden=\"{{virtualHostHidden}}\"/>`,
`(_ctx, _cache) => {
return { a: _ctx.id1, b: 'id' in _ctx.$.type.props }
return { a: _gei(_ctx, _ctx.id1) }
}`,
options
)
assert(
`<image id="id1" :id="id1"/>`,
`<image id=\"{{a || virtualHostId === '' ? 'id1' : virtualHostId}}\" class=\"{{[virtualHostClass]}}\" style=\"{{virtualHostStyle}}\" hidden=\"{{virtualHostHidden}}\"/>`,
`<image id=\"{{a}}\" class=\"{{[virtualHostClass]}}\" style=\"{{virtualHostStyle}}\" hidden=\"{{virtualHostHidden}}\"/>`,
`(_ctx, _cache) => {
return { a: 'id' in _ctx.$.type.props }
return { a: _gei(_ctx, 'id1') }
}`,
options
)
assert(
`<view :id="id1"></view>`,
`<view id=\"{{a}}\" style=\"{{$eS[a] + ';' + virtualHostStyle}}\" class=\"{{[virtualHostClass]}}\" hidden=\"{{virtualHostHidden}}\"></view>`,
`(_ctx, _cache) => {
const __returned__ = { a: _sei('id' in _ctx.$.type.props || _ctx.virtualHostId === '' ? _ctx.id1 : _ctx.virtualHostId, 'view'), b: _s(_ses('id' in _ctx.$.type.props || _ctx.virtualHostId === '' ? _ctx.id1 : _ctx.virtualHostId)) }
const __returned__ = { a: _sei(_gei(_ctx, _ctx.id1), 'view'), b: _s(_ses(_gei(_ctx, _ctx.id1))) }
return __returned__
}`,
optionsX
Expand All @@ -174,7 +174,7 @@ describe('complier: options with mergeVirtualHostAttributes', () => {
`<view id="page"><image ref="img" /></view>`,
`<view id=\"{{c}}\" style=\"{{$eS[c] + ';' + virtualHostStyle}}\" class=\"{{[virtualHostClass]}}\" hidden=\"{{virtualHostHidden}}\"><image ref=\"img\" id=\"r0-2a9ec0b0\" style=\"{{$eS[a]}}\"/></view>`,
`(_ctx, _cache) => {
const __returned__ = { a: _sei('r0-2a9ec0b0', 'image', 'img'), b: _s(_ses('r0-2a9ec0b0')), c: _sei('id' in _ctx.$.type.props || _ctx.virtualHostId === '' ? 'page' : _ctx.virtualHostId, 'view'), d: _s(_ses('id' in _ctx.$.type.props || _ctx.virtualHostId === '' ? 'page' : _ctx.virtualHostId)) }
const __returned__ = { a: _sei('r0-2a9ec0b0', 'image', 'img'), b: _s(_ses('r0-2a9ec0b0')), c: _sei(_gei(_ctx, 'page'), 'view'), d: _s(_ses(_gei(_ctx, 'page'))) }
return __returned__
}`,
optionsX
Expand All @@ -183,7 +183,7 @@ describe('complier: options with mergeVirtualHostAttributes', () => {
`<view id="page" ref="page"><image ref="img" /></view>`,
`<view ref=\"page\" id=\"{{c}}\" style=\"{{$eS[c] + ';' + virtualHostStyle}}\" class=\"{{[virtualHostClass]}}\" hidden=\"{{virtualHostHidden}}\"><image ref=\"img\" id=\"r0-2a9ec0b0\" style=\"{{$eS[a]}}\"/></view>`,
`(_ctx, _cache) => {
const __returned__ = { a: _sei('r0-2a9ec0b0', 'image', 'img'), b: _s(_ses('r0-2a9ec0b0')), c: _sei(('id' in _ctx.$.type.props || _ctx.virtualHostId === '' ? 'page' : _ctx.virtualHostId) !== '' ? 'id' in _ctx.$.type.props || _ctx.virtualHostId === '' ? 'page' : _ctx.virtualHostId : 'r1-2a9ec0b0', 'view', 'page'), d: _s(_ses(('id' in _ctx.$.type.props || _ctx.virtualHostId === '' ? 'page' : _ctx.virtualHostId) !== '' ? 'id' in _ctx.$.type.props || _ctx.virtualHostId === '' ? 'page' : _ctx.virtualHostId : 'r1-2a9ec0b0')) }
const __returned__ = { a: _sei('r0-2a9ec0b0', 'image', 'img'), b: _s(_ses('r0-2a9ec0b0')), c: _sei(_gei(_ctx, 'page', 'r1-2a9ec0b0'), 'view', 'page'), d: _s(_ses(_gei(_ctx, 'page', 'r1-2a9ec0b0'))) }
return __returned__
}`,
optionsX
Expand All @@ -192,57 +192,57 @@ describe('complier: options with mergeVirtualHostAttributes', () => {
test('user component attrs with mergeVirtualHostAttributes', () => {
assert(
`<view><custom-image/></view>`,
`<view class="{{[virtualHostClass]}}" style="{{virtualHostStyle}}" hidden="{{virtualHostHidden}}" id="{{virtualHostId}}"><custom-image u-i="2a9ec0b0-0"/></view>`,
`<view class=\"{{[virtualHostClass]}}\" style=\"{{virtualHostStyle}}\" hidden=\"{{virtualHostHidden}}\" id=\"{{a}}\"><custom-image u-i=\"2a9ec0b0-0\"/></view>`,
`(_ctx, _cache) => {
return {}
return { a: _gei(_ctx, '') }
}`,
options
)
assert(
`<view><custom-image v-show="show"/></view>`,
`<view class="{{[virtualHostClass]}}" style="{{virtualHostStyle}}" hidden="{{virtualHostHidden}}" id="{{virtualHostId}}"><custom-image virtualHostHidden="{{!a}}" hidden="{{!a}}" u-i="2a9ec0b0-0"/></view>`,
`<view class=\"{{[virtualHostClass]}}\" style=\"{{virtualHostStyle}}\" hidden=\"{{virtualHostHidden}}\" id=\"{{b}}\"><custom-image virtualHostHidden=\"{{!a}}\" hidden=\"{{!a}}\" u-i=\"2a9ec0b0-0\"/></view>`,
`(_ctx, _cache) => {
return { a: _ctx.show }
return { a: _ctx.show, b: _gei(_ctx, '') }
}`,
options
)
assert(
`<view><custom-image id="i"/></view>`,
`<view class="{{[virtualHostClass]}}" style="{{virtualHostStyle}}" hidden="{{virtualHostHidden}}" id="{{virtualHostId}}"><custom-image id="i" virtualHostId="i" u-i="2a9ec0b0-0" u-p="{{a||''}}"/></view>`,
`<view class=\"{{[virtualHostClass]}}\" style=\"{{virtualHostStyle}}\" hidden=\"{{virtualHostHidden}}\" id=\"{{b}}\"><custom-image id=\"i\" virtualHostId=\"i\" u-i=\"2a9ec0b0-0\" u-p=\"{{a||''}}\"/></view>`,
`(_ctx, _cache) => {
return { a: _p({ id: 'i' }) }
return { a: _p({ id: 'i' }), b: _gei(_ctx, '') }
}`,
options
)
assert(
`<view><custom-image :id="i"/></view>`,
`<view class="{{[virtualHostClass]}}" style="{{virtualHostStyle}}" hidden="{{virtualHostHidden}}" id="{{virtualHostId}}"><custom-image id="{{a}}" virtualHostId="{{a}}" u-i="2a9ec0b0-0" u-p="{{b||''}}"/></view>`,
`<view class=\"{{[virtualHostClass]}}\" style=\"{{virtualHostStyle}}\" hidden=\"{{virtualHostHidden}}\" id=\"{{c}}\"><custom-image id=\"{{a}}\" virtualHostId=\"{{a}}\" u-i=\"2a9ec0b0-0\" u-p=\"{{b||''}}\"/></view>`,
`(_ctx, _cache) => {
return { a: _ctx.i, b: _p({ id: _ctx.i }) }
return { a: _ctx.i, b: _p({ id: _ctx.i }), c: _gei(_ctx, '') }
}`,
options
)
assert(
`<custom-view v-show="show"><image /></custom-view>`,
`<custom-view u-s="{{['d']}}" u-i="2a9ec0b0-0" class="{{[virtualHostClass]}}" virtualHostClass="{{[virtualHostClass]}}" style="{{virtualHostStyle}}" virtualHostStyle="{{virtualHostStyle}}" hidden="{{virtualHostHidden !== '' ? virtualHostHidden : !a}}" virtualHostHidden="{{virtualHostHidden !== '' ? virtualHostHidden : !a}}" id="{{virtualHostId}}" virtualHostId="{{virtualHostId}}"><image/></custom-view>`,
`<custom-view u-s=\"{{['d']}}\" u-i=\"2a9ec0b0-0\" class=\"{{[virtualHostClass]}}\" virtualHostClass=\"{{[virtualHostClass]}}\" style=\"{{virtualHostStyle}}\" virtualHostStyle=\"{{virtualHostStyle}}\" hidden=\"{{virtualHostHidden !== '' ? virtualHostHidden : !a}}\" virtualHostHidden=\"{{virtualHostHidden !== '' ? virtualHostHidden : !a}}\" id=\"{{b}}\" virtualHostId=\"{{b}}\"><image/></custom-view>`,
`(_ctx, _cache) => {
return { a: _ctx.show }
return { a: _ctx.show, b: _gei(_ctx, '') }
}`,
options
)
assert(
`<view><custom-image class="class1" style="width:100%"/></view>`,
`<view class="{{[virtualHostClass]}}" style="{{virtualHostStyle}}" hidden="{{virtualHostHidden}}" id="{{virtualHostId}}"><custom-image class="class1" virtualHostClass="class1" style="width:100%" virtualHostStyle="width:100%" u-i="2a9ec0b0-0"/></view>`,
`<view class=\"{{[virtualHostClass]}}\" style=\"{{virtualHostStyle}}\" hidden=\"{{virtualHostHidden}}\" id=\"{{a}}\"><custom-image class=\"class1\" virtualHostClass=\"class1\" style=\"width:100%\" virtualHostStyle=\"width:100%\" u-i=\"2a9ec0b0-0\"/></view>`,
`(_ctx, _cache) => {
return {}
return { a: _gei(_ctx, '') }
}`,
options
)
assert(
`<custom-view><custom-image/></custom-view>`,
`<custom-view u-s="{{['d']}}" u-i="2a9ec0b0-0" class="{{[virtualHostClass]}}" virtualHostClass="{{[virtualHostClass]}}" style="{{virtualHostStyle}}" virtualHostStyle="{{virtualHostStyle}}" hidden="{{virtualHostHidden}}" virtualHostHidden="{{virtualHostHidden}}" id="{{virtualHostId}}" virtualHostId="{{virtualHostId}}"><custom-image u-i="2a9ec0b0-1,2a9ec0b0-0"/></custom-view>`,
`<custom-view u-s=\"{{['d']}}\" u-i=\"2a9ec0b0-0\" class=\"{{[virtualHostClass]}}\" virtualHostClass=\"{{[virtualHostClass]}}\" style=\"{{virtualHostStyle}}\" virtualHostStyle=\"{{virtualHostStyle}}\" hidden=\"{{virtualHostHidden}}\" virtualHostHidden=\"{{virtualHostHidden}}\" id=\"{{a}}\" virtualHostId=\"{{a}}\"><custom-image u-i=\"2a9ec0b0-1,2a9ec0b0-0\"/></custom-view>`,
`(_ctx, _cache) => {
return {}
return { a: _gei(_ctx, '') }
}`,
options
)
Expand Down
8 changes: 4 additions & 4 deletions packages/uni-mp-compiler/__tests__/uniElement.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe('compiler: transform UniElement.style.setProperty', () => {
`<view id="view"/>`,
`<view id="{{a}}" style="{{$eS[a] + ';' + virtualHostStyle}}" class="{{[virtualHostClass]}}" hidden="{{virtualHostHidden}}"/>`,
`(_ctx, _cache) => {
const __returned__ = { a: _sei(_ctx.virtualHostId !== '' ? _ctx.virtualHostId : 'view', 'view'), b: _s(_ses(_ctx.virtualHostId !== '' ? _ctx.virtualHostId : 'view')) }
const __returned__ = { a: _sei(_gei(_ctx, 'view'), 'view'), b: _s(_ses(_gei(_ctx, 'view'))) }
return __returned__
}`,
{
Expand All @@ -48,7 +48,7 @@ describe('compiler: transform UniElement.style.setProperty', () => {
`<custom id="custom"/>`,
`<custom u-i="2a9ec0b0-0" id="{{a}}" virtualHostId="{{a}}" u-p="{{b||''}}" class="{{[virtualHostClass]}}" virtualHostClass="{{[virtualHostClass]}}" style="{{virtualHostStyle}}" virtualHostStyle="{{virtualHostStyle}}" hidden="{{virtualHostHidden}}" virtualHostHidden="{{virtualHostHidden}}"/>`,
`(_ctx, _cache) => {
const __returned__ = { a: _ctx.virtualHostId !== '' ? _ctx.virtualHostId : 'custom', b: _p({ id: _ctx.virtualHostId !== '' ? _ctx.virtualHostId : 'custom' }) }
const __returned__ = { a: _gei(_ctx, 'custom'), b: _p({ id: _gei(_ctx, 'custom') }) }
return __returned__
}`,
{
Expand Down Expand Up @@ -95,7 +95,7 @@ describe('compiler: transform UniElement.style.setProperty', () => {
`<view id="view" style="color:red"/>`,
`<view id="{{a}}" style="{{'color:red' + ';' + $eS[a] + ';' + virtualHostStyle}}" class="{{[virtualHostClass]}}" hidden="{{virtualHostHidden}}"/>`,
`(_ctx, _cache) => {
const __returned__ = { a: _sei(_ctx.virtualHostId !== '' ? _ctx.virtualHostId : 'view', 'view'), b: _s(_ses(_ctx.virtualHostId !== '' ? _ctx.virtualHostId : 'view')) }
const __returned__ = { a: _sei(_gei(_ctx, 'view'), 'view'), b: _s(_ses(_gei(_ctx, 'view'))) }
return __returned__
}`,
{
Expand Down Expand Up @@ -142,7 +142,7 @@ describe('compiler: transform UniElement.style.setProperty', () => {
`<view :id="viewId"/>`,
`<view id="{{a}}" style="{{$eS[a] + ';' + virtualHostStyle}}\" class=\"{{[virtualHostClass]}}\" hidden=\"{{virtualHostHidden}}"/>`,
`(_ctx, _cache) => {
const __returned__ = { a: _sei(_ctx.virtualHostId !== '' ? _ctx.virtualHostId : _ctx.viewId, 'view'), b: _s(_ses(_ctx.virtualHostId !== '' ? _ctx.virtualHostId : _ctx.viewId)) }
const __returned__ = { a: _sei(_gei(_ctx, _ctx.viewId), 'view'), b: _s(_ses(_gei(_ctx, _ctx.viewId))) }
return __returned__
}`,
{
Expand Down
2 changes: 2 additions & 0 deletions packages/uni-mp-compiler/src/runtimeHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const TO_DISPLAY_STRING = Symbol(`toDisplayString`)
export const WITH_MODEL_MODIFIERS = Symbol(`withModelModifiers`)
export const SET_UNI_ELEMENT_ID = Symbol(`setUniElementId`)
export const SET_UNI_ELEMENT_STYLE = Symbol(`setUniElementStyle`)
export const GEN_UNI_ELEMENT_ID = Symbol(`genUniElementId`)

registerRuntimeHelpers({
[V_ON]: 'o',
Expand All @@ -35,4 +36,5 @@ registerRuntimeHelpers({
[STRINGIFY_JSON]: 'j',
[SET_UNI_ELEMENT_ID]: 'sei',
[SET_UNI_ELEMENT_STYLE]: 'ses',
[GEN_UNI_ELEMENT_ID]: 'gei',
})
Loading

0 comments on commit 8a3403f

Please sign in to comment.