- v-model and v-show directives are now exposed as public - compiler-used runtime helpers are now exposed for TS tooling, but marked as @private close #1329
37 lines
843 B
TypeScript
37 lines
843 B
TypeScript
// SFC scoped style ID management.
|
|
// These are only used in esm-bundler builds, but since exports cannot be
|
|
// conditional, we can only drop inner implementations in non-bundler builds.
|
|
|
|
import { withCtx } from './withRenderContext'
|
|
|
|
export let currentScopeId: string | null = null
|
|
const scopeIdStack: string[] = []
|
|
|
|
/**
|
|
* @private
|
|
*/
|
|
export function pushScopeId(id: string) {
|
|
scopeIdStack.push((currentScopeId = id))
|
|
}
|
|
|
|
/**
|
|
* @private
|
|
*/
|
|
export function popScopeId() {
|
|
scopeIdStack.pop()
|
|
currentScopeId = scopeIdStack[scopeIdStack.length - 1] || null
|
|
}
|
|
|
|
/**
|
|
* @private
|
|
*/
|
|
export function withScopeId(id: string): <T extends Function>(fn: T) => T {
|
|
return ((fn: Function) =>
|
|
withCtx(function(this: any) {
|
|
pushScopeId(id)
|
|
const res = fn.apply(this, arguments)
|
|
popScopeId()
|
|
return res
|
|
})) as any
|
|
}
|