Skip to content

Commit

Permalink
fix: do not drop SFC runtime behavior code in global builds
Browse files Browse the repository at this point in the history
fix #873
  • Loading branch information
yyx990803 committed Mar 23, 2020
1 parent 4126a9d commit 4c1a193
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 29 deletions.
1 change: 0 additions & 1 deletion packages/runtime-core/src/componentProxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ export const PublicInstanceProxyHandlers: ProxyHandler<any> = {
}
return publicGetter(target)
} else if (
__BUNDLER__ &&
(cssModule = type.__cssModules) &&
(cssModule = cssModule[key])
) {
Expand Down
28 changes: 10 additions & 18 deletions packages/runtime-core/src/helpers/scopeId.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,20 @@ export let currentScopeId: string | null = null
const scopeIdStack: string[] = []

export function pushScopeId(id: string) {
if (__BUNDLER__) {
scopeIdStack.push((currentScopeId = id))
}
scopeIdStack.push((currentScopeId = id))
}

export function popScopeId() {
if (__BUNDLER__) {
scopeIdStack.pop()
currentScopeId = scopeIdStack[scopeIdStack.length - 1] || null
}
scopeIdStack.pop()
currentScopeId = scopeIdStack[scopeIdStack.length - 1] || null
}

export function withScopeId(id: string): <T extends Function>(fn: T) => T {
if (__BUNDLER__) {
return ((fn: Function) =>
withCtx(function(this: any) {
pushScopeId(id)
const res = fn.apply(this, arguments)
popScopeId()
return res
})) as any
} else {
return undefined as any
}
return ((fn: Function) =>
withCtx(function(this: any) {
pushScopeId(id)
const res = fn.apply(this, arguments)
popScopeId()
return res
})) as any
}
18 changes: 8 additions & 10 deletions packages/runtime-core/src/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -563,16 +563,14 @@ function baseCreateRenderer(
}

// scopeId
if (__BUNDLER__) {
if (scopeId) {
hostSetScopeId(el, scopeId)
}
const treeOwnerId = parentComponent && parentComponent.type.__scopeId
// vnode's own scopeId and the current patched component's scopeId is
// different - this is a slot content node.
if (treeOwnerId && treeOwnerId !== scopeId) {
hostSetScopeId(el, treeOwnerId + '-s')
}
if (scopeId) {
hostSetScopeId(el, scopeId)
}
const treeOwnerId = parentComponent && parentComponent.type.__scopeId
// vnode's own scopeId and the current patched component's scopeId is
// different - this is a slot content node.
if (treeOwnerId && treeOwnerId !== scopeId) {
hostSetScopeId(el, treeOwnerId + '-s')
}

// children
Expand Down

0 comments on commit 4c1a193

Please sign in to comment.