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
}
}
// 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