text stringlengths 14 100k | source stringclasses 1
value | repo stringclasses 810
values | language stringclasses 13
values |
|---|---|---|---|
<|fim_prefix|>import {
BaseTransition,
type BaseTransitionProps,
BaseTransitionPropsValidators,
DeprecationTypes,
type FunctionalComponent,
assertNumber,
compatUtils,
h,
} from '@vue/runtime-core'
import { extend, isArray, isObject, toNumber } from '@vue/shared'
const TRANSITION = 'transition'
const AN... | fim | vuejs/core | typescript |
<|fim_suffix|> }
prevChildren = []
if (children) {
for (let i = 0; i < children.length; i++) {
const child = children[i]
if (
child.el &&
child.el instanceof Element &&
// Hidden v-show nodes have no previous layout box to animate from.
... | fim | vuejs/core | typescript |
<|fim_prefix|>import {
type DirectiveBinding,
type DirectiveHook,
type ObjectDirective,
type VNode,
nextTick,
warn,
} from '@vue/runtime-core'
import { addEventListener } from '../modules/events'
import {
invokeArrayFns,
isArray,
isSet,
looseEqual,
looseIndexOf,
looseToNumber,
} from '@vue/share... | fim | vuejs/core | typescript |
<|fim_prefix|>import {
type ComponentInternalInstance,
DeprecationTypes,
type Directive,
type LegacyConfig,
compatUtils,
getCurrentInstance,
} from '@vue/runtime-core'
import { hyphenate, isArray } from '@vue/shared'
const systemModifiers = ['ctrl', 'shift', 'alt', 'meta'] as const
type SystemModifiers = (... | fim | vuejs/core | typescript |
<|fim_suffix|> if (value) {
transition.beforeEnter(el)
setDisplay(el, true)
transition.enter(el)
} else {
transition.leave(el, () => {
setDisplay(el, false)
})
}
} else {
setDisplay(el, value)
}
},
beforeUnmount(el, { value }) {
setDi... | fim | vuejs/core | typescript |
<|fim_suffix|>".`)
return EMPTY_OBJ
}
return mod as Record<string, string>
} else {
/* v8 ignore start */
if (__DEV__) {
warn(`useCssModule() is not supported in the global build.`)
}
return EMPTY_OBJ
/* v8 ignore stop */
}
}
<|fim_prefix|>import { getCurrentInstance, warn } ... | fim | vuejs/core | typescript |
<|fim_suffix|> onUnmounted(() => ob.disconnect())
})
}
function setVarsOnVNode(vnode: VNode, vars: Record<string, unknown>) {
if (__FEATURE_SUSPENSE__ && vnode.shapeFlag & ShapeFlags.SUSPENSE) {
const suspense = vnode.suspense!
vnode = suspense.activeBranch!
if (suspense.pendingBranch && !suspense.is... | fim | vuejs/core | typescript |
import {
type App,
type CreateAppFunction,
type DefineComponent,
DeprecationTypes,
type Directive,
type ElementNamespace,
type HydrationRenderer,
type Renderer,
type RootHydrateFunction,
type RootRenderFunction,
compatUtils,
createHydrationRenderer,
createRenderer,
isRuntimeOnly,
warn,
} f... | fim | vuejs/core | typescript |
<|fim_prefix|>// Note: this file is auto concatenated to the end of the bundled d.ts during
// build.
// This code is based on react definition in DefinitelyTyped published under the MIT license.
// Repository: https://github.com/DefinitelyTyped/DefinitelyTyped
// Path in the repository: types/react/index.d.... | fim | vuejs/core | typescript |
<|fim_suffix|>st xlinkNS = 'http://www.w3.org/1999/xlink'
export function patchAttr(
el: Element,
key: string,
value: any,
isSVG: boolean,
instance?: ComponentInternalInstance | null,
isBoolean: boolean = isSpecialBooleanAttr(key),
): void {
if (isSVG && key.startsWith('xlink:')) {
if (value == null)... | fim | vuejs/core | typescript |
<|fim_prefix|>import { type ElementWithTransition, vtcKey } from '../components/Transition'
// compiler should normalize class + <|fim_suffix|>(
el: Element,
value: string | null,
isSVG: boolean,
): void {
// directly setting className should be faster than setAttribute in theory
// if this is an element dur... | fim | vuejs/core | typescript |
<|fim_prefix|>import { NOOP, hyphenate, isArray, isFunction } from '@vue/shared'
import {
type ComponentInternalInstance,
ErrorCodes,
callWithAsyncErrorHandling,
warn,
} from '@vue/runtime-core'
interface Invoker extends EventListener {
value: EventValue
attached: number
}
type EventValue = Function | Fun... | fim | vuejs/core | typescript |
<|fim_prefix|>import { DeprecationTypes, compatUtils, warn } from '@vue/runtime-core'
import { includeBooleanAttr } from '@vue/shared'
import { unsafeToTrustedHTML } from '../nodeOps'
// functions. The user is responsible for using them with only trusted content.
export function patchDOMProp(
el: any,
key: string,... | fim | vuejs/core | typescript |
<|fim_prefix|>import { capitalize, hyphenate, isArray, isString } from '@vue/shared'
import { camelize, warn } from '@vue/runtime-core'
import {
type VShowElement,
vShowHidden,
vShowOriginalDisplay,
} from '../directives/vShow'
import { CSS_VAR_TEXT } from '../helpers/useCssVars'
type Style = string | Record<str... | fim | vuejs/core | typescript |
<|fim_prefix|>import { warn } from '@vue/runtime-core'
import type { RendererOptions } from '@vue/runtime-core'
import type {
TrustedHTML,
TrustedTypePolicy,
TrustedTypesWindow,
} from 'trusted-types/lib'
let policy: Pick<TrustedTypePolicy, 'name' | 'createHTML'> | undefined =
undefined
const tt =
typeof wi... | fim | vuejs/core | typescript |
<|fim_suffix|>}
// #1787, #2840 form property on form elements is readonly and must be set as
// attribute.
if (key === 'form') {
return false
}
// #1526 <input list> must be set as attribute
if (key === 'list' && el.tagName === 'INPUT') {
return false
}
// #2766 <textarea type> must be set a... | fim | vuejs/core | typescript |
<|fim_prefix|>import {
NodeOpTypes,
type TestElement,
TestNodeTypes,
type TestText,
dumpOps,
h,
nextTick,
nodeOps,
reactive,
ref,
render,
resetOps,
serialize,
triggerEvent,
} from '../src'
describe('test renderer', () => {
it('should work', () => {
<|fim_suffix|> nextTick()
const upd... | fim | vuejs/core | typescript |
'use strict'
if (process.env.NODE_ENV === 'production') {
module.exports = require('./dist/runtime-test.cjs.prod.js')
} else {
module.exports = require('./dist/runtime-test.cjs.js')
}
<|endoftext|> | fim | vuejs/core | javascript |
<|fim_prefix|>import {
type CreateAppFunction,
type RootRenderFunction,
type VNode,
createRenderer,
} from '@vue/runtime-core'
import { type TestElement, nodeOps } from './nodeOps'
import { patchProp } from './patchProp'
import { serializeInner } from './serialize'
import { extend } from '@vue/shared'
const { ... | fim | vuejs/core | typescript |
<|fim_suffix|> {
TEXT = 'text',
ELEMENT = 'element',
COMMENT = 'comment',
}
export enum NodeOpTypes {
CREATE = 'create',
INSERT = 'insert',
REMOVE = 'remove',
SET_TEXT = 'setText',
SET_ELEMENT_TEXT = 'setElementText',
PATCH = 'patch',
}
export interface TestElement {
id: number
type: TestNodeTyp... | fim | vuejs/core | typescript |
<|fim_suffix|>) : key.slice(2).toLowerCase()
;(el.eventListeners || (el.eventListeners = {}))[event] = nextValue
}
}
<|fim_prefix|>import { NodeOpTypes, type TestElement, logNodeOp } from './nodeOps'
import { isOn } from '@vue/shared'
export function patchProp(
el: TestElement,
key: string,
prevValue: any,... | fim | vuejs/core | typescript |
<|fim_prefix|>import {
type TestComment,
type TestElement,
type TestNode,
TestNodeTypes,
type TestText,
} from './nodeOps'
import { isOn } from '@vue/shared'
export function serialize(
node: TestNode,
indent: number = 0,
dep<|fim_suffix|>rn isOn(key) || value == null
? ``
: value === ``... | fim | vuejs/core | typescript |
<|fim_prefix|>import { isArray } from '@vue/shared'
import type { TestElement } from './nodeOps'
export function triggerEvent(
el: TestElement,
event: string,
payload:<|fim_suffix|>t { eventListeners } = el
if (eventListeners) {
const listener = eventListeners[event]
if (listener) {
if (isArray(l... | fim | vuejs/core | typescript |
<|fim_prefix|>import { bench, describe } from 'vitest'
import { createBuffer as _crea<|fim_suffix|> bench(
'string with nested async',
() => {
for (let i = 0; i < 10; i += 1) {
if (i % 3 === 0) {
const buffer = createBuffer()
buffer.push('hello')
stringNestedBuffer.p... | fim | vuejs/core | typescript |
<|fim_suffix|>// should only be called twice since access should be cached
// during the render phase
expect(getterSpy).toHaveBeenCalledTimes(2)
})
test('props modifiers in render attrs', async () => {
const app = createApp({
setup() {
return () =>
h(
... | fim | vuejs/core | typescript |
<|fim_suffix|> id="foo" class="bar"/>`,
}
// pass to parent, fallthrough to child and merge
const app = createApp(Parent, { class: 'baz' })
expect(await renderToString(app)).toBe(
`<div id="foo" class="bar baz"></div>`,
)
})
})
<|fim_prefix|>import { createApp } from 'vue'
import { renderToS... | fim | vuejs/core | typescript |
<|fim_suffix|>ns: {
whitespace: 'condense',
},
components: {
ChildComponent: {
template: `<span>Hello world</span>`,
},
},
})
app.config.compilerOptions.whitespace = 'preserve'
expect(await renderToString(app)).toBe(
`<div><span>Hello world</span><... | fim | vuejs/core | typescript |
<|fim_suffix|>
const app = createSSRApp(App)
const html = await renderToString(app)
expect(html).toMatch('value: 2')
})
<|fim_prefix|>import { computed, createSSRApp, defineComponent, <|fim_middle|>h, reactive, ref } from 'vue'
import { renderToString } from '../src/renderToString'
// #5208 reported memory leak ... | fim | vuejs/core | typescript |
<|fim_prefix|>import { renderToString } from '../src/renderToString'
import {
createApp,
h,
mergeProps,
ref,
resolveDirective,
unref,
vModelCheckbox,
vModelDynamic,
vModelRadio,
vModelText,
vShow,
withDirectives,
} from 'vue'
import { ssrGetDirectiveProps, ssrRenderAttrs } from '../src'
describ... | fim | vuejs/core | typescript |
<|fim_prefix|>import { createApp, createVNode } from 'vue'
import { renderToString } from '../src'
describe('ssr: dynamic component', () => {
te<|fim_suffix|></one></one>`,
}),
),
).toBe(
`<div><!--[--><div style=\"display:none;\"><!--[-->hi<!--]--></div><!--]--></div>`,
)
})
test('r... | fim | vuejs/core | typescript |
<|fim_prefix|>import { ssrInterpolate } from '../src/helpers/ssrInterpolate'
import { escapeHtml } from '@vue/shared'
test('ssr: interpolate', () => {
expect(ssrInterpolate(0)).toBe(`0`)
expect(ssrInterpolate(`foo`)).toBe(`foo`)
ex<|fim_suffix|> ssrInterpolate({
foo: 1,
bar: `<div>`,
}),
).toB... | fim | vuejs/core | typescript |
<|fim_prefix|>import {
ssrRenderAttr,
ssrRenderAttrs,
ssrRenderClass,
ssrRenderStyle,
} from '../src/helpers/ssrRenderAttrs'
import { escapeHtml } from '@vue/shared'
describe('ssr: renderAttrs', () => {
test('ignore reserved props', () => {
expect(
ssrRenderAttrs({
key: 1,
ref_key: ... | fim | vuejs/core | typescript |
<|fim_suffix|> y=2'])
})
it('should iterate iterables lazily without intermediate allocation', () => {
const yielded: number[] = []
const rendered: number[] = []
function* gen() {
for (let i = 0; i < 3; i++) {
yielded.push(i)
yield i
}
}
ssrRenderList(gen(), (item,... | fim | vuejs/core | typescript |
import { createApp, h, mergeProps, withCtx } from 'vue'
import { renderToString } from '../src/renderToString'
import { ssrRenderAttrs, ssrRenderComponent, ssrRenderSlot } from '../src'
describe('ssr: scopedId runtime behavior', () => {
test('id on component root', async () => {
const Child = {
ssrRender: ... | fim | vuejs/core | typescript |
import { createApp, defineAsyncComponent, h } from 'vue'
import { renderToString } from '../src/renderToString'
const components = {
one: {
template: `<div><slot/></div>`,
},
}
describe('ssr: slot', () => {
test('text slot', async () => {
expect(
await renderToString(
createApp({
... | fim | vuejs/core | typescript |
<|fim_prefix|>import { Suspense, createApp, defineComponent, h } from 'vue'
import { renderToString } from '../src/renderToString'
import { ssrRenderComponent } from '../src/helpers/ssrRenderComponent'
import { ssrRenderSuspense } from '../src/helpers/ssrRenderSuspense'
describe('SSR Suspense', () => {
const Resolvi... | fim | vuejs/core | typescript |
<|fim_suffix|> template: '<async-component />',
components: { asyncComponent },
}),
ctx,
)
expect(html).toBe('<!--teleport start--><!--teleport end-->')
expect(ctx.teleports!['#target']).toBe(
`<!--teleport start anchor--><div>content</div><!--teleport anchor-->`,
)
})
te... | fim | vuejs/core | typescript |
<|fim_prefix|>import {
ssrGetDynamicModelProps,
ssrRenderDynamicModel,
// ssrGetDynamicModelProps
} from '../src/helpers/ssrVModelHelpers'
describe('ssr: v-model helpers', () => {
test('ssrRenderDynamicModel', () => {
expect(ssrRenderDynamicModel(null, 'foo', null)).toBe(` value="foo"`)
expect(ssrRende... | fim | vuejs/core | typescript |
<|fim_prefix|>import {
createSSRApp,
defineComponent,
h,
nextTick,
onScopeDispose,
ref,
watch,
watchEffect,
withAsyncContext,
} from 'vue'
import { type SSRContext, renderToString } from '../src'
const gc = () =>
new Promise<void>(resolve => {
setTimeout(() => {
global.gc!()
resolve... | fim | vuejs/core | typescript |
<|fim_prefix|>import { bench, describe } from 'vitest'
import { type SSRBuffer, createBuffer } from '../src/render'
import { unrollBuffer as _unrollBuffer } from '../src/renderToString'
// move to local const to avoid import access overhead
// https://github.com/vitest-dev/vitest/issues/6903
const unrollBuffer = _unr... | fim | vuejs/core | typescript |
<|fim_prefix|>import { createApp, defineAsyncComponent, h } from 'vue'
import { ReadableStream, TransformStream } from 'node:stream/web'
import { pipeToWebWritable, renderToWebStream } from '../src'
beforeEach(() => {
// @ts-expect-error
global.ReadableStream = ReadableStream
})
afterEach(() => {
// @ts-expect-... | fim | vuejs/core | typescript |
<|fim_suffix|>erer.cjs.prod.js')
} else {
module.exports = require('./dist/server-renderer.cjs.js')
}
<|fim_prefix|>'use strict'
if (process.env.NODE_ENV === 'production') {
module.exports<|fim_middle|> = require('./dist/server-rend<|endoftext|> | fim | vuejs/core | javascript |
<|fim_suffix|>) {
return cached
}
finalCompilerOptions.onError = (err: CompilerError) => {
if (__DEV__) {
const message = `[@vue/server-renderer] Template compilation error: ${err.message}`
const codeFrame =
err.loc &&
generateCodeFrame(
template as string,
e... | fim | vuejs/core | typescript |
<|fim_suffix|>ops) {
return (
dir.getSSRProps(
{
dir,
instance: ssrUtils.getComponentPublicInstance(instance.$),
value,
oldValue: undefined,
arg,
modifiers,
},
null as any,
) || {}
)
}
return {}
}
<|fim_prefix|>i... | fim | vuejs/core | typescript |
<|fim_suffix|> '@vue/shared'
export function ssrInterpolate(value: unknown): string {
return escapeHtml(toDisplayString(value))
}
<|fim_prefix|>impo<|fim_middle|>rt { escapeHtml, toDisplayString } from<|endoftext|> | fim | vuejs/core | typescript |
import {
escapeHtml,
isArray,
isObject,
isRenderableAttrValue,
isSVGTag,
stringifyStyle,
} from '@vue/shared'
import {
includeBooleanAttr,
isBooleanAttr,
isOn,
isSSRSafeAttrName,
isString,
makeMap,
normalizeClass,
normalizeCssVarValue,
normalizeStyle,
propsToAttrMap,
} from '@vue/shared'... | fim | vuejs/core | typescript |
<|fim_suffix|>= null,
slotScopeId?: string,
): SSRBuffer | Promise<SSRBuffer> {
return renderComponentVNode(
createVNode(comp, props, children),
parentComponent,
slotScopeId,
)
}
<|fim_prefix|>import {
type Component,
type ComponentInternalInstance,
type Slots,
createVNode,
} from 'vue'
import... | fim | vuejs/core | typescript |
<|fim_suffix|> < source; i++) {
renderItem(i + 1, i)
}
} else if (isObject(source)) {
if (source[Symbol.iterator as any]) {
let i = 0
for (const item of source as Iterable<any>) {
renderItem(item, i++)
}
} else {
const keys = Object.keys(source)
for (let i = 0, ... | fim | vuejs/core | typescript |
<|fim_suffix|>r.length
if (
transition &&
slotBuffer[0] === '<!--[-->' &&
slotBuffer[end - 1] === '<!--]-->'
) {
start++
end--
}
if (start < end) {
for (let i = start; i < end; i++) {
push(slotBuffer[i])
}... | fim | vuejs/core | typescript |
<|fim_suffix|>e {
push(`<!---->`)
}
}
<|fim_prefix|>import type { PushFn } from '../render'
// Must remain synchronous: compiled output is `ssrRenderSuspense(_push, ...)`,
// not `_push(ssrRenderSuspense(...))`, so any returned Promise <|fim_middle|>(and its
// rejection) would be silently discarded.
export func... | fim | vuejs/core | typescript |
<|fim_suffix|>
let teleportContent: SSRBufferItem
if (disabled) {
contentRenderFn(parentPush)
teleportContent = `<!--teleport start anchor--><!--teleport anchor-->`
} else {
const { getBuffer, push } = createBuffer()
push(`<!--teleport start anchor-->`)
contentRenderFn(push)
push(`<!--te... | fim | vuejs/core | typescript |
<|fim_prefix|>import { isArray, looseEqual, looseIndexOf } from '@vue/shared'
import { ssrRenderAttr } from './ssrRenderAttrs'
export const ssrLooseEqual = looseEqual as (a: unknown, b: unknown) => boolean
export function ssrLooseContain(arr: unknown[], value: unknown): boolean {
return looseIndexOf(arr, value) > -... | fim | vuejs/core | typescript |
<|fim_suffix|>xport * from './internal'
<|fim_prefix|>import { initDirectivesForSSR } from 'vue'
initDirectivesForSSR()
// public
export type { SSRContext } from './render'
export { renderToString } from './renderToString'
export {
renderToSimpleStream,
renderToNodeStream,
pipeToNodeWritable,
renderToWebStream... | fim | vuejs/core | typescript |
<|fim_suffix|>el helpers
export {
ssrLooseEqual,
ssrLooseContain,
ssrRenderDynamicModel,
ssrGetDynamicModelProps,
} from './helpers/ssrVModelHelpers'
<|fim_prefix|>// internal runtime helpers
export { renderVNode as ssrRenderVNode } from './render'
export { ssrRenderComponent } from './helpers/ssrRenderComponen... | fim | vuejs/core | typescript |
import {
Comment,
type Component,
type ComponentInternalInstance,
type DirectiveBinding,
Fragment,
type FunctionalComponent,
Static,
Text,
type VNode,
type VNodeArrayChildren,
type VNodeProps,
mergeProps,
ssrUtils,
warn,
} from 'vue'
import {
NOOP,
ShapeFlags,
escapeHtml,
escapeHtmlC... | fim | vuejs/core | typescript |
<|fim_suffix|> cancelled = true
},
})
}
export function pipeToWebWritable(
input: App | VNode,
context: SSRContext | undefined = {},
writable: WritableStream,
): void {
const writer = writable.getWriter()
const encoder = new TextEncoder()
// #4287 CloudFlare workers do not implement `ready` propert... | fim | vuejs/core | typescript |
<|fim_prefix|>import {
type App,
type VNode,
createApp,
createVNode,
ssrContextKey,
ssrUtils,
} from 'vue'
import { isPromise, isString } from '@vue/shared'
import { type SSRBuffer, type SSRContext, renderComponentVNode } from './render'
const { isVNode } = ssrUtils
function nestedUnrollBuffer(
buffer: ... | fim | vuejs/core | typescript |
<|fim_suffix|>ulti-line highlights', () => {
const source = `
<div attr="some
multiline
attr
">
</div>
`.trim()
const attrStart = source.indexOf(`attr=`)
const attrEnd = source.indexOf(`">`) + 1
expect(generateCodeFrame(source, attrStart, attrEnd)).toMatchSnapshot()
})
test('invalid start an... | fim | vuejs/core | typescript |
import { normalizeCssVarValue } from '../src'
describe('utils/cssVars', () => {
test('should normalize css binding values correctly', () => {
expect(normalizeCssVarValue(null)).toBe('initial')
expect(normalizeCssVarValue(undefined)).toBe('initial')
expect(normalizeCssVarValue('')).toBe(' ')
expect(no... | fim | vuejs/core | typescript |
import { escapeHtml, escapeHtmlComment } from '../src'
describe('escapeHtml', () => {
test('ssr: escapeHTML', () => {
expect(escapeHtml(`foo`)).toBe(`foo`)
expect(escapeHtml(true)).toBe(`true`)
expect(escapeHtml(false)).toBe(`false`)
expect(escapeHtml(`a && b`)).toBe(`a && b`)
expect(esca... | fim | vuejs/core | typescript |
/**
* @vitest-environment jsdom
*/
import { looseEqual } from '../src'
describe('utils/looseEqual', () => {
test('compares booleans correctly', () => {
expect(looseEqual(true, true)).toBe(true)
expect(looseEqual(false, false)).toBe(true)
expect(looseEqual(true, false)).toBe(false)
expect(looseEqual... | fim | vuejs/core | typescript |
<|fim_prefix|>import {
normalizeClass,
normalizeProps,
normalizeStyle,
parseStringStyle,
stringifyStyle,
} from '../src'
describe('normalizeClass', () => {
test('handles undefined correctly', () => {
expect(normalizeClass(undefined)).toEqual('')
})
test('handles string correctly', () => {
expe... | fim | vuejs/core | typescript |
<|fim_prefix|>/**
* @vitest-environment jsdom
*/
import { computed, ref } from '@vue/reactivity'
import { toDisplayString } from '../src'
describe('toDisplayString', () => {
test('nullish values', () => {
expect(toDisplayString(null)).toBe('')
expect(toDisplayString(undefined)).toBe('')
})
test('primi... | fim | vuejs/core | typescript |
<|fim_suffix|>)
}
<|fim_prefix|>'use strict'
if (process.env.NODE_ENV === 'production') {
module.exports = requi<|fim_middle|>re('./dist/shared.cjs.prod.js')
} else {
module.exports = require('./dist/shared.cjs.js'<|endoftext|> | fim | vuejs/core | javascript |
<|fim_suffix|>encing
const newlineSequences = lines.filter((_, idx) => idx % 2 === 1)
lines = lines.filter((_, idx) => idx % 2 === 0)
let count = 0
const res: string[] = []
for (let i = 0; i < lines.length; i++) {
count +=
lines[i].length +
((newlineSequences[i] && newlineSequences[i].length)... | fim | vuejs/core | typescript |
<|fim_suffix|>' : value
}
if (typeof value !== 'number' || !Number.isFinite(value)) {
if (__DEV__) {
console.warn(
'[Vue warn] Invalid value used for CSS binding. Expected a string or a finite number but received:',
value,
)
}
}
return String(value)
}
<|fim_prefix|>/**
* N... | fim | vuejs/core | typescript |
<|fim_prefix|>import { makeMap } from './makeMap'
/**
* On the client we only need to offer special cases for boolean attributes that
* have different names from their corresponding dom properties:
* - itemscope -> N/A
* - allowfullscreen -> allowFullscreen
* - formnovalidate -> formNoValidate
* - ismap -> isMap... | fim | vuejs/core | typescript |
<|fim_prefix|>// These tag configs are shared between compiler-dom and runtime-dom, so they
// must be extracted in shared to avoid creating a dependency between the two.
import { makeMap } from './makeMap'
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element
const HTML_TAGS =
'html,body,base,head,link,meta,... | fim | vuejs/core | typescript |
<|fim_prefix|>const escapeRE = /["'&<>]/
export function escapeHtml(string: unknown): string {
const str = '' + string
const match = escapeRE.exec(str)
if (!match) {
return str
}
let html = ''
let escaped: string
let index: number
let lastIndex = 0
for (index = match.index; index < str.length; ... | fim | vuejs/core | typescript |
<|fim_prefix|>import { makeMap } from './makeMap'
export const EMPTY_OBJ: { readonly [key: string]: any } = __DEV__
? Object.freeze({})
: {}
export const EMPTY_ARR: readonly never[] = __DEV__ ? Object.freeze([]) : []
export const NOOP = (): void => {}
/**
* Always return false.
*/
export const NO = () => false... | fim | vuejs/core | typescript |
<|fim_prefix|>import { makeMap } from './makeMap'
const GLOBAL<|fim_suffix|>nent,Math,Number,Date,Array,' +
'Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt,console,Error,Symbol'
export const isGloballyAllowed: (key: string) => boolean =
/*@__PURE__*/ makeMap(GLOBALS_ALLOWED)
/** @deprecated use `isGloball... | fim | vuejs/core | typescript |
<|fim_suffix|>splayString'
export * from './typeUtils'
export * from './cssVars'
<|fim_prefix|>export { makeMap } from './makeMap'
export * from './general'
export * from './patchFlags'
export * from './shapeFlags'
export * from './slotFlags'
export * from './globalsAllowList'
export * from './codeframe'
export * from ... | fim | vuejs/core | typescript |
<|fim_prefix|>import { isArray, isDate, isObject, isSymbol } from './general'
function looseCompareArrays(a: any[], b: any[]) {
if (a.length !== b.length) return false
let equal = true
for (let i = 0; equal && i < a.length; i++) {
equal = looseEqual(a[i], b[i])
}
return equal
}
export function looseEqua... | fim | vuejs/core | typescript |
<|fim_prefix|>/**
* Make a map and return a function for checking if a key
* is in that map.
* IMPORTANT: all calls of this f<|fim_suffix|>-shake them if necessary.
*/
/*@__NO_SIDE_EFFECTS__*/
export function makeMap(str: string): (key: string) => boolean {
const map = Object.create(null)
for (const key of str... | fim | vuejs/core | typescript |
<|fim_prefix|>import { hyphenate, isArray, isObject, isString } from './general'
export type NormalizedStyl<|fim_suffix|> ? parseStringStyle(item)
: (normalizeStyle(item) as NormalizedStyle)
if (normalized) {
for (const key in normalized) {
res[key] = normalized[key]
}
}... | fim | vuejs/core | typescript |
<|fim_prefix|>/**
* Patch flags are optimization hints generated by the compiler.
* when a block with dynamicChildren is encountered during diff, the algorithm
* enters "optimized mode". In this mode, we know that the vdom is produced by
* a render function generated by the compiler, so the algorithm only needs to
... | fim | vuejs/core | typescript |
export enum ShapeFlags {
ELEMENT = 1,
FUNCTIONAL_COMPONENT = 1 << 1,
STATEFUL_COMPONENT = 1 << 2,
TEXT_CHILDREN = 1 << 3,
ARRAY_CHILDREN = 1 << 4,
SLOTS_CHILDREN = 1 << 5,
TELEPORT = 1 << 6,
SUSPENSE = 1 << 7,
COMPONENT_SHOULD_KEEP_ALIVE = 1 << 8,
COMPONENT_KEPT_ALIVE = 1 << 9,
COMPONENT = ShapeFl... | fim | vuejs/core | typescript |
<|fim_prefix|>export enum SlotFlags {
/**
* Stable slots that only reference slot props or context state. The slot
* can fully capture <|fim_suffix|>
* Dev only
*/
export const slotFlagsText: Record<SlotFlags, string> = {
[SlotFlags.STABLE]: 'STABLE',
[SlotFlags.DYNAMIC]: 'DYNAMIC',
[SlotFlags.FORWARDED... | fim | vuejs/core | typescript |
<|fim_suffix|>(val)
? toDisplayString(val.value)
: JSON.stringify(val, replacer, 2)
: String(val)
}
const replacer = (_key: string, val: unknown): any => {
if (isRef(val)) {
return replacer(_key, val.value)
} else if (isMap(val)) {
return {
[`Map(${val.size})`]: [...val.en... | fim | vuejs/core | typescript |
<|fim_prefix|>export type Prettify<T> = { [K in keyof T]: T[K] } & {}
<|fim_suffix|>) => void : never
) extends (k: infer I) => void
? I
: never
// make keys required but keep undefined values
export type LooseRequired<T> = { [P in keyof (T & Required<T>)]: T[P] }
// If the type T accepts type "any", output type ... | fim | vuejs/core | typescript |
<|fim_suffix|>ing
@camelCase="handler"
@CAPScase="handler"
@PascalCase="handler"
v-on="{
camelCase: handler2,
CAPScase: handler2,
PascalCase: handler2
}" />`,
methods: {
handler,
handler2,
},
}).mount(container)
expect(handler).toHaveBeenCal... | fim | vuejs/core | typescript |
import { E2E_TIMEOUT, setupPuppeteer } from './e2eUtils'
import path from 'node:path'
import { createApp, ref } from 'vue'
describe('e2e: TransitionGroup', () => {
const { page, html, nextFrame, timeout } = setupPuppeteer()
const baseUrl = `file://${path.resolve(__dirname, './transition.html')}`
const duration ... | fim | vuejs/core | typescript |
<|fim_prefix|>export default {
main: [
{
sha: 'd1527fbee422c7170e56845e55b49c4fd6de72a7',
node_id:
'MDY6Q29tbWl0MTM3MDc4NDg3OmQxNTI3ZmJlZTQyMmM3MTcwZTU2ODQ1ZTU1YjQ5YzRmZDZkZTcyYTc=',
commit: {
author: {
name: 'Haoqun Jiang',
email: 'haoqunjiang@gmail.com',
... | fim | vuejs/core | typescript |
<|fim_suffix|>ext('label[for="main"]')).toBe('main')
expect(await text('label[for="v2-compat"]')).toBe('v2-compat')
expect(await isChecked('#main')).toBe(true)
expect(await isChecked('#v2-compat')).toBe(false)
expect(await text('p')).toBe('vuejs/core@main')
expect(await count('li')).toBe(3)
expe... | fim | vuejs/core | typescript |
<|fim_suffix|>}
function timeout(time: number) {
return page.evaluate(time => {
return new Promise(r => {
setTimeout(r, time)
})
}, time)
}
function nextFrame() {
return page.evaluate(() => {
return new Promise(resolve => {
requestAnimationFrame(() => {
re... | fim | vuejs/core | typescript |
<|fim_suffix|>ount('th:nth-child(1) .arrow.asc')).toBe(1)
expect(await count('th:nth-child(2) .arrow.asc')).toBe(1)
await assertTable([
{ name: 'Bruce Lee', power: 9000 },
{ name: 'Chuck Norris', power: Infinity },
{ name: 'Jackie Chan', power: 7000 },
{ name: 'Jet Li', power: 8000 },
... | fim | vuejs/core | typescript |
<|fim_prefix|>import path from 'node:path'
import { setupPuppeteer } from './e2eUtils'
import type { Ref } from '../../src/runtime'
declare const window: Window & {
isHydrated: boolean
isRootMounted: boolean
teardownCalled?: boolean
show: Ref<boolean>
resolveLoader: () => void
}
describe('async component hy... | fim | vuejs/core | typescript |
<|fim_prefix|>import path from 'node:path'
import { E2E_TIMEOUT, expectByPolling, setupPuppeteer } from './e2eUtils'
describe('e2e: markdown', () => {
const { page, isVisible, value, html } = setupPuppeteer()
async function testMarkdown(apiType: 'classic' | 'composition') {
const baseUrl = `file://${path.reso... | fim | vuejs/core | typescript |
<|fim_suffix|>},
},
},
template: `
<button id="addBtn" @click="add">add</button>
<button id="toggleBtn" @click="click">button</button>
<div v-if="toggle">
<template v-for="item in items" :key="item">
text
<div>{{ item ... | fim | vuejs/core | typescript |
<|fim_suffix|> },
}
customElements.define('my-element', defineSSRCustomElement(def))
customElements.define(
'my-element-async',
defineSSRCustomElement(
defineAsyncComponent(
() =>
new Promise(r => {
;(window as any).resolve = () => r(def)
... | fim | vuejs/core | typescript |
<|fim_prefix|>import path from 'node:path'
import { E2E_TIMEOUT, setupPuppeteer } from './e2eUtils'
declare const globalStats: {
label: string
value: number
}[]
declare function valueToPoint(
value: number,
index: number,
total: number,
): {
x: number
y: number
}
describe('e2e: svg', () => {
const { ... | fim | vuejs/core | typescript |
<|fim_prefix|>import path from 'node:path'
import { E2E_TIMEOUT, setupPuppeteer } from './e2eUtils'
describe('e2e: todomvc', () => {
const {
page,
click,
isVisible,
count,
text,
value,
isChecked,
isFocused,
classList,
enterValue,
clearValue,
timeout,
} = setupPuppete... | fim | vuejs/core | typescript |
<|fim_suffix|> click('#demo > .item > ul > .add')
expect((await children('#demo li ul')).length).toBe(6)
expect(await text('#demo > .item > ul > .item:nth-child(1)')).toContain(
'hello',
)
expect(await text('#demo > .item > ul > .item:nth-child(2)')).toContain(
'wat',
)
expect(await ... | fim | vuejs/core | typescript |
<|fim_suffix|>d')
return function render() {
return h('div', msg.value)
}
},
}).mount('#app')
})
expect(await html('#app')).toContain('<div>✅success: hello world</div>')
},
E2E_TIMEOUT,
)
test(
'should render static vnode without error... | fim | vuejs/core | typescript |
<|fim_prefix|>import path from 'node:path'
import { setupPuppeteer } from './e2eUtils'
const { page, click, isChecked } = setupPuppeteer()
import { nextTick } from 'vue'
beforeEach(async () => {
await page().addScriptTag({
path: path.resolve(__dirname, '../../dist/vue.global.js'),
})
await page().setConte<|... | fim | vuejs/core | typescript |
<|fim_suffix|> `<div v-for="v of ['a']">{{ v }}</div>`,
}
const container = document.createElement('div')
createApp(App).mount(container)
expect(EMPTY_ARR.length).toBe(0)
})
test('BigInt support', () => {
const app = createApp({
template: `<div>{{ BigInt(BigInt(100000111)) + BigInt(200000... | fim | vuejs/core | typescript |
<|fim_suffix|>('foo')
// set a transition class on the <div> - which is only respected on non-svg
// patches
;(f2 as any)[vtcKey] = ['baz']
cls.value = 'bar'
await nextTick()
expect(f1.getAttribute('class')).toBe('bar')
expect(f2.className).toBe('bar baz')
})
})
<|fim_prefix|>// MathML lo... | fim | vuejs/core | typescript |
<|fim_suffix|>onfig.compilerOptions.whitespace = 'preserve'
const root = document.createElement('div')
app.mount(root)
expect(root.firstChild!.childNodes.length).toBe(3)
expect(root.firstChild!.childNodes[1].nodeType).toBe(Node.TEXT_NODE)
})
test('delimiters', () => {
const app = createApp({
... | fim | vuejs/core | typescript |
<|fim_prefix|>// SVG logic is technically dom-specific, but the logic is placed in core
// because splitting it out of core would lead to unnecessary complexity in both
// the renderer and compiler implementations.
// Related files:
// - runtime-core/src/renderer.ts
// - compiler-core/src/transforms/transformElement.ts... | fim | vuejs/core | typescript |
<|fim_suffix|>
<|fim_prefix|>module.exports = require('@vue/c<|fim_middle|>ompiler-sfc')<|endoftext|> | fim | vuejs/core | javascript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.