text stringlengths 14 100k | source stringclasses 1
value | repo stringclasses 810
values | language stringclasses 13
values |
|---|---|---|---|
<|fim_suffix|>ndexOf
_i: (arr: Array<any>, val: any) => number
// resolveFilter
_f: (id: string) => Function
// renderList
_l: (val: any, render: Function) => Array<VNode> | null
// renderSlot
_t: (
name: string,
fallback?: Array<VNode>,
props?: Record<string, any>
) => Array<VNode> | null
... | fim | vuejs/vue | typescript |
<|fim_suffix|>T
delete: <T>(target: Object | Array<T>, key: string | number) => void
nextTick: (fn: Function, context?: Object) => void | Promise<any>
use: (plugin: Function | Object) => GlobalAPI
mixin: (mixin: Object) => GlobalAPI
compile: (template: string) => {
render: Function
staticRenderFns: Ar... | fim | vuejs/vue | typescript |
<|fim_suffix|> interface ArrayLikeMatchers<T> {
toHaveBeenWarned(): void
toHaveBeenTipped(): void
}
}
<|fim_prefix|>declare module 'de-indent' {
export default function deindent(input: string): string
}
declare namespace <|fim_middle|>jasmine {
interface Matchers<T> {
toHaveBeenWarned(): void
to... | fim | vuejs/vue | typescript |
<|fim_prefix|>import VNode from 'core/vdom/vnode'
import { DebuggerEvent } from 'v3/debug'
import { SetupContext } from 'v3/apiSetup'
import { Component } from './component'
export type InternalComponentOptions = {
_isComponent: true
parent: Component
_parentVnode: VNode
render?: Function
staticRenderFns?: A... | fim | vuejs/vue | typescript |
<|fim_suffix|>port type ElementContext = {
type: 'Element'
children: Array<VNode>
rendered: number
endTag: string
total: number
}
export type ComponentContext = {
type: 'Component'
prevActive: Component
}
export type RenderState =
| ComponentContext
| ComponentWithCacheContext
| ElementContext
<|f... | fim | vuejs/vue | typescript |
<|fim_suffix|>stackoverflow.com/questions/49927523/disallow-call-with-any/49928360#49928360
export type IfAny<T, Y, N> = 0 extends 1 & T ? Y : N
<|fim_prefix|>// If the type T accepts type "any",<|fim_middle|> output type Y, otherwise output type N.
// https://<|endoftext|> | fim | vuejs/vue | typescript |
import VNode from 'core/vdom/vnode'
import { Ref } from 'v3'
import { Component } from './component'
import { ASTModifiers } from './compiler'
/**
* @internal
*/
export type VNodeChildren =
| Array<null | VNode | string | number | VNodeChildren>
| string
/**
* @internal
*/
export type VNodeComponentOptions = ... | fim | vuejs/vue | typescript |
<|fim_prefix|>import { warn, isFunction, isObject } from 'core/util'
interface AsyncComponentOptions {
loader: Function
loadingComponent?: any
errorComponent?: any
delay?: number
timeout?: number
suspensible?: boolean
onError?: (
error: Error,
retry: () => void,
fail: () => void,
attempts... | fim | vuejs/vue | typescript |
<|fim_suffix|>InjectionKey<T> | string,
defaultValue: T | (() => T),
treatDefaultAsFactory: true
): T
export function inject(
key: InjectionKey<any> | string,
defaultValue?: unknown,
treatDefaultAsFactory = false
) {
// fallback to `currentRenderingInstance` so that this can be called in
// a functional c... | fim | vuejs/vue | typescript |
<|fim_prefix|>import { DebuggerEvent } from './debug'
import { Component } from 'types/component'
import { mergeLifecycleHook, warn } from '../core/util'
import { currentInstance } from './currentInstance'
function c<|fim_suffix|>setup().`
)
return
}
return injectHook(target, hookName, fn)
}
}
... | fim | vuejs/vue | typescript |
<|fim_suffix|>r compiled render fn
const proxy = (vm._setupProxy = {})
for (const key in setupResult) {
if (key !== '__sfc') {
proxyWithRefUnwrap(proxy, setupResult, key)
}
}
}
} else if (__DEV__ && setupResult !== undefined) {
warn(
`setup... | fim | vuejs/vue | typescript |
<|fim_prefix|>import { isRef, Ref } from './reactivity/ref'
import { ComputedRef } from './reactivity/computed'
import { isReactive, isShallow } from './reactivity/reactive'
import {
warn,
noop,
isArray,
isFunction,
emptyObject,
hasChanged,
isServerRendering,
invokeWithErrorHandling
} from 'core/util'
i... | fim | vuejs/vue | typescript |
<|fim_suffix|>tInstance }
}
/**
* @internal
*/
export function setCurrentInstance(vm: Component | null = null) {
if (!vm) currentInstance && currentInstance._scope.off()
currentInstance = vm
vm && vm._scope.on()
}
<|fim_prefix|>import { Component } from 'types/component'
export let currentInstance: Component ... | fim | vuejs/vue | typescript |
<|fim_suffix|>
type: TrackOpTypes | TriggerOpTypes
key?: any
newValue?: any
oldValue?: any
}
<|fim_prefix|>import { TrackOpTypes, TriggerOpTypes } from './reactivity/operations'
export interface DebuggerOptions {
onTrack?: (event: DebuggerEvent) => void
onTrigger?: (event: DebuggerEvent) => void
}
export ... | fim | vuejs/vue | typescript |
<|fim_suffix|>setup function.`
)
}
return createElement(currentInstance!, type, props, children, 2, true)
}
<|fim_prefix|>import { createElement } from '../core/vdom/create-elemen<|fim_middle|>t'
import { currentInstance } from './currentInstance'
import { warn } from 'core/util'
/**
* @internal this functi... | fim | vuejs/vue | typescript |
<|fim_suffix|>Ref,
ToRefs,
UnwrapRef,
ShallowRef,
ShallowUnwrapRef,
RefUnwrapBailTypes,
CustomRefFactory
} from './reactivity/ref'
export {
reactive,
isReactive,
isReadonly,
isShallow,
isProxy,
shallowReactive,
markRaw,
toRaw,
ReactiveFlags,
ShallowReactive,
UnwrapNestedRefs
} from '.... | fim | vuejs/vue | typescript |
<|fim_suffix|>her) {
if (watcher.dirty) {
watcher.evaluate()
}
if (Dep.target) {
if (__DEV__ && Dep.target.onTrack) {
Dep.target.onTrack({
effect: Dep.target,
target: ref,
type: TrackOpTypes.GET,
key: 'value'... | fim | vuejs/vue | typescript |
<|fim_prefix|>import Wat<|fim_suffix|> = (...args: any[]) => any
/**
* @internal since we are not exposing this in Vue 2, it's used only for
* internal testing.
*/
export function effect(fn: () => any, scheduler?: (cb: any) => void) {
const watcher = new Watcher(currentInstance, fn, noop, {
sync: true
})
... | fim | vuejs/vue | typescript |
<|fim_prefix|>import Watcher from 'core/observer/watcher'
import { warn } from 'core/util'
export let activeEffectScope: EffectScope | undefined
export class EffectScope {
/**
* @internal
*/
active = true
/**
* @internal
*/
effects: Watcher[] = []
/**
* @internal
*/
cleanups: (() => void... | fim | vuejs/vue | typescript |
<|fim_prefix|>// using literal strings instead of numbers so that it's <|fim_suffix|>port const enum TrackOpTypes {
GET = 'get',
TOUCH = 'touch'
}
export const enum TriggerOpTypes {
SET = 'set',
ADD = 'add',
DELETE = 'delete',
ARRAY_MUTATION = 'array mutation'
}
<|fim_middle|>easier to inspect
// debugger ... | fim | vuejs/vue | typescript |
<|fim_suffix|>. It also does not auto-unwrap refs (even at the
* root level).
*/
export function shallowReactive<T extends object>(
target: T
): ShallowReactive<T> {
makeReactive(target, true)
def(target, ReactiveFlags.IS_SHALLOW, true)
return target
}
function makeReactive(target: any, shallow: boolean) {
... | fim | vuejs/vue | typescript |
<|fim_prefix|>import { def, warn, isPlainObject, isArray } from 'core/util'
import {
isCollectionType,
isReadonly,
isShallow,
ReactiveFlags,
UnwrapNestedRefs
} from './reactive'
import { isRef, Ref, RefFlag } from './ref'
type Primitive = string | number | boolean | bigint | symbol | undefined | null
type Bu... | fim | vuejs/vue | typescript |
<|fim_prefix|>import { defineReactive } from 'core/observer/index'
import {
isReactive,
ReactiveFlags,
type ShallowReactiveMarker
} from './reactive'
import type { IfAny } from 'types/utils'
import Dep from 'core/observer/dep'
import { warn, isArray, def, isServerRendering } from 'core/util'
import { TrackOpTypes... | fim | vuejs/vue | typescript |
<|fim_suffix|>sModule(name = '$style'): Record<string, string> {
/* istanbul ignore else */
if (!__GLOBAL__) {
if (!currentInstance) {
__DEV__ && warn(`useCssModule must be called inside setup()`)
return emptyObject
}
const mod = currentInstance[name]
if (!mod) {
__DEV__ &&
... | fim | vuejs/vue | typescript |
<|fim_prefix|>import { watchPostEffect } from '../'
import { inBrowser, warn } from 'core/util'
import { currentInstance } from '../currentInstance'
/**
* Runtime helper for SFC's CSS variable injection feature.
* @private
*/
export function useCssVars(
getter: (
vm: Record<string<|fim_suffix|> for (const ke... | fim | vuejs/vue | typescript |
<|fim_prefix|>// @vitest-environment node
import path from 'path'
import { E2E_TIMEOUT, setupPuppeteer } from './e2eUtils'
describe('basic-ssr', () => {
const { page, text, click, isChecked } = setupPuppeteer()
test(
'should work',
async () => {
await page().goto(
`file://${path.resolve(__di... | fim | vuejs/vue | typescript |
// @vitest-environment node
import path from 'path'
import { E2E_TIMEOUT, setupPuppeteer } from './e2eUtils'
describe('basic-ssr', () => {
const { page, text } = setupPuppeteer()
test(
'should work',
async () => {
await page().goto(`file://${path.resolve(__dirname, `basic-ssr.html`)}`)
expect(... | fim | vuejs/vue | typescript |
export default {
main: [
{
sha: '0948d999f2fddf9f90991956493f976273c5da1f',
node_id:
'MDY6Q29tbWl0MTE3MzAzNDI6MDk0OGQ5OTlmMmZkZGY5ZjkwOTkxOTU2NDkzZjk3NjI3M2M1ZGExZg==',
commit: {
author: {
name: 'Evan You',
email: 'yyx990803@gmail.com',
date: '2017-1... | fim | vuejs/vue | typescript |
<|fim_suffix|>ha=(.*)$/)
if (!match) {
req.continue()
} else {
const ret = JSON.stringify(mocks[match[1] as 'main' | 'dev'])
req.respond({
status: 200,
contentType: 'application/json',
headers: { 'Access-Control-Allow-Origin': '*' },
body: ret
... | fim | vuejs/vue | typescript |
<|fim_prefix|>import path from 'path'
import puppeteer from<|fim_suffix|> {
if (e.type() === 'error') {
const err = e.args()[0]
console.error(
`Error from Puppeteer-loaded page:\n`,
err._remoteObject.description
)
}
})
})
afterEach(async () => {
await... | fim | vuejs/vue | typescript |
import { setupPuppeteer, getExampleUrl, E2E_TIMEOUT } from './e2eUtils'
interface TableData {
name: string
power: number
}
describe('e2e: grid', () => {
const { page, click, text, count, typeValue, clearValue } = setupPuppeteer()
const columns = ['name', 'power'] as const
async function assertTable(data: T... | fim | vuejs/vue | typescript |
<|fim_suffix|>r')).toBe(true)
expect(await value('textarea')).toBe('# hello')
expect(await html('#editor div')).toBe('<h1 id="hello">hello</h1>\n')
await page().type('textarea', '\n## foo\n\n- bar\n- baz')
// assert the output is not updated yet because of debounce
// debounce has become unstable ... | fim | vuejs/vue | typescript |
<|fim_prefix|>import { setupPuppeteer, getExampleUrl, E2E_TIMEOUT } 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 { page, click, co... | fim | vuejs/vue | typescript |
<|fim_suffix|>oBe('edited again!')
// empty value should remove
await click('.todo label', { clickCount: 2 })
await enterValue('.todo:nth-child(1) .edit', ' ')
expect(await count('.todo')).toBe(3)
// toggle all
await click('.toggle-all+label')
expect(await count('.todo.completed')).toBe(3)... | fim | vuejs/vue | typescript |
<|fim_suffix|>'#demo ul > .item:nth-child(1) > ul')).toBe(2)
}
test(
'classic',
async () => {
await testTree('classic')
},
E2E_TIMEOUT
)
test(
'composition',
async () => {
await testTree('composition')
},
E2E_TIMEOUT
)
})
<|fim_prefix|>import { setupPuppeteer, get... | fim | vuejs/vue | typescript |
<|fim_suffix|>age: () =>
`Expected element${pass ? ' ' : ' not '}to have class ${cls}`
}
}
})
<|fim_prefix|>expect.extend({
toHaveClass(el: Element,<|fim_middle|> cls: string) {
const pass = el.classList
? el.classList.contains(cls)
: (el.getAttribute('class') || '').split(/\s+/g).indexO... | fim | vuejs/vue | typescript |
<|fim_prefix|>// wrap tests to support test('foo', done => {...}) interface
const _test = test
const wait = (): [() => void, Promise<void>] => {
let done
const p = new Promise<void>((resolve, reject) => {
done = resolve
done.fail = reject
})
return [done, p]
}
con<|fim_suffix|>})
;['skip', 'only', 't... | fim | vuejs/vue | typescript |
<|fim_suffix|>=> {
const options = {}
options[name] = () => {}
new Vue(options)
expect(`Invalid value for option "${name}"`).toHaveBeenWarned()
})
it(`Options ${name}: should not warn valid object value`, () => {
const options = {}
options[name] = {}
new Vue(options)
expect(`Invalid... | fim | vuejs/vue | typescript |
<|fim_prefix|>import { SpyInstance } from 'vitest'
expect.extend({
toHaveBeenWarned(received: string) {
asserted.add(received)
const passed = warn.mock.calls.some(args =>
String(args[0]).includes(received)
)
if (passed) {
return {
pass: true,
message: () => `expected "${re... | fim | vuejs/vue | typescript |
<|fim_prefix|>e<|fim_suffix|>rue)
if (event === 'click') {
// @ts-expect-error Button is readonly
;(e as MouseEvent).button = 0
}
if (process) process(e)
target.dispatchEvent(e)
}
<|fim_middle|>xport function triggerEvent(target, event, process) {
const e = document.createEvent('HTMLEvents')
e.initE... | fim | vuejs/vue | typescript |
<|fim_suffix|>core/vdom/vnode'
export function createTextVNode(text) {
return new VNode(undefined, undefined, undefined, text)
}
<|fim_prefix|>import VNode from <|fim_middle|>'<|endoftext|> | fim | vuejs/vue | typescript |
<|fim_prefix|>import Vue from 'vue'
// helper for async assertions.
// Use like this:
//
// vm.a = 123
// waitForUpdate(() => {
// expect(vm.$el.textContent).toBe('123')
// vm.a = 234
// })
// .then(() => {
// // more assertions...
// })
// .then(done)
interface Job extends Function {
wait?: boolean
fail?: ... | fim | vuejs/vue | typescript |
<|fim_prefix|>interface Chainer {
then(next: F<|fim_suffix|>> {
(...args: any[]): any
calls: {
count(): number
}
}
addMatchers(matchers: any): void
}
<|fim_middle|>unction): this
thenWaitFor(n: number | Function): this
end(endFn: Function): void
}
declare function waitForUpdate(cb: Function... | fim | vuejs/vue | typescript |
<|fim_prefix|>export { waitForUpdate } from '../helpers/wait-for-update'
export { nextFr<|fim_suffix|>pacity ${duration}ms ease;
}
.group-move {
-webkit-transition: -webkit-transform ${duration}ms ease;
transition: transform ${duration}ms ease;
}
.v-appear, .v-enter, .v-leave-active,
.te... | fim | vuejs/vue | typescript |
const featureFlags = require('../../scripts/feature-flags')
process.env.CHROME_BIN = require('puppeteer').executablePath()
const define = {
__DEV__: `true`,
'process.env.CI': String(!!process.env.CI)
}
for (const key in featureFlags) {
define[`process.env.${key}`] = String(featureFlags[key])
}
module.exports =... | fim | vuejs/vue | javascript |
import Vue from 'vue'
import { injectStyles, waitForUpdate, nextFrame } from './helpers'
describe('Transition group', () => {
const { duration, buffer } = injectStyles()
let el
beforeEach(() => {
el = document.createElement('div')
document.body.appendChild(el)
})
function createBasicVM(useIs?, appe... | fim | vuejs/vue | typescript |
<|fim_prefix|>import Vue from 'vue'
import { injectStyles, waitForUpdate, nextFrame } from './helpers'
describe('Transition mode', () => {
const { duration, buffer } = injectStyles()
const components = {
one: { template: '<div>one</div>' },
two: { template: '<div>two</div>' }
}
let el
beforeEach(() ... | fim | vuejs/vue | typescript |
<|fim_suffix|> .then(() => {
expect(vm.$el.innerHTML).toBe(
'<div class="test test-leave-active test-leave-to">one</div>' +
'<div class="test">two</div>'
)
})
.thenWaitFor(duration + buffer)
.then(() => {
expect(vm.$el.innerHTML).toBe('<div class="test">... | fim | vuejs/vue | typescript |
<|fim_suffix|>.thenWaitFor(nextFrame)
.then(() => {
expect(vm.$el.children[0].className).toBe(
'test test-appear-active test-appear-to'
)
})
.thenWaitFor(duration + buffer)
.then(() => {
expect(vm.$el.children[0].className).toBe('test')
vm.ok = false
... | fim | vuejs/vue | typescript |
<|fim_prefix|>import Vue from 'vue'
describe('Component async', () => {
const oldSetTimeout = setTimeout
const oldClearTimeout = clearTimeout
// will contain pending timeouts set during the test iteration
// will contain the id of the timeout as the key, and the millisecond timeout as the value
// this help... | fim | vuejs/vue | typescript |
<|fim_suffix|> :include="include">
<component :is="view"></component>
</keep-alive>
</div>
`,
data: {
view: 'one',
include: 'one,two'
},
components
}).$mount()
vm.view = 'two'
waitForUpdate(() => {
assertHookCalls(one, [1, 1, 1, 1,... | fim | vuejs/vue | typescript |
<|fim_prefix|>import Vue from 'vue'
describe('Component scoped slot', () => {
it('default slot', done => {
const vm = new Vue({
template: `
<test ref="test">
<template slot-scope="props">
<span>{{ props.msg }}</span>
</template>
</test>
`,
compone... | fim | vuejs/vue | typescript |
<|fim_prefix|>import Vue from 'vue'
describe('Component slot', () => {
let vm, child
function mount(options) {
vm = new Vue({
data: {
msg: 'parent message'
},
template: `<div><test>${options.parentContent || ''}</test></div>`,
components: {
test: {
template: op... | fim | vuejs/vue | typescript |
import Vue from 'vue'
describe('Component', () => {
it('static', () => {
const vm = new Vue({
template: '<test></test>',
components: {
test: {
data() {
return { a: 123 }
},
template: '<span>{{a}}</span>'
}
}
}).$mount()
expect(vm... | fim | vuejs/vue | typescript |
<|fim_suffix|>und in
---> <Three>
<Two>
<One>
<Root>`
).toHaveBeenWarned()
})
it('generate correct component hierarchy trace (recursive)', () => {
let i = 0
const one = {
name: 'one',
render: h => (i++ < 5 ? h(one) : h(two))
}
const two = {
name: 't... | fim | vuejs/vue | typescript |
<|fim_suffix|>className = 'okay'
vm.test.value = 'bye'
waitForUpdate(() => {
expect(vm.$el.id).toBe('hi')
expect(vm.$el.className).toBe('okay')
expect(vm.$el.value).toBe('bye')
}).then(done)
})
it('bind array', done => {
const vm = new Vue({
template: '<input v-bind="test">'... | fim | vuejs/vue | typescript |
<|fim_suffix|>
waitForUpdate(() => {
expect(vm.$el.className).toBe('a b')
}).then(done)
})
// css static classes should only contain a single space in between,
// as all the text inside of classes is shipped as a JS string
// and this could lead to useless spacing in static classes
it('condense... | fim | vuejs/vue | typescript |
<|fim_prefix|>import Vue from 'vue'
describe('Directive v-cloak', () => {
it('should be removed after compile', () => {
cons<|fim_suffix|>expect(vm.$el.hasAttribute('v-cloak')).toBe(false)
})
})
<|fim_middle|>t el = document.createElement('div')
el.setAttribute('v-cloak', '')
const vm = new Vue({ el })... | fim | vuejs/vue | typescript |
<|fim_suffix|>.reverse()
waitForUpdate(() => {
assertMarkup()
vm.list.splice(1, 1)
})
.then(() => {
assertMarkup()
vm.list.splice(1, 0, { a: 2 })
})
.then(done)
function assertMarkup() {
const markup = vm.list
.map(function (item) {
retu... | fim | vuejs/vue | typescript |
<|fim_prefix|>import Vue from 'vue'
describe('Directive v-html', () => {
it('should render html', () => {
const vm = new Vue({
template: '<div v-html="a"></div>',
data: { a: 'hello' }
}).$mount()
expect(vm.$el.innerHTML).toBe('hello')
})
it('should encode html entities', () => {
c<|f... | fim | vuejs/vue | typescript |
import Vue from 'vue'
describe('Directive v-if', () => {
it('should check if value is truthy', () => {
const vm = new Vue({
template: '<div><span v-if="foo">hello</span></div>',
data: { foo: true }
}).$mount()
expect(vm.$el.innerHTML).toBe('<span>hello</span>')
})
it('should check if val... | fim | vuejs/vue | typescript |
<|fim_suffix|>)', done => {
const vm = new Vue({
data: {
test: [{ a: 1 }]
},
template: `
<div>
<input type="checkbox" v-model="test" :value="{ a: 1 }">
<input type="checkbox" v-model="test" :value="[2]">
</div>
`
}).$mount()
document.body.a... | fim | vuejs/vue | typescript |
<|fim_prefix|>import Vue from 'vue'
describe('Directive v-model component', () => {
it('should work', done => {
const vm = new Vue({
data: {
msg: 'hello'
},
template: `
<div>
<p>{{ msg }}</p>
<test v-model="msg"></test>
</div>
`,
component... | fim | vuejs/vue | typescript |
<|fim_suffix|>hange it to password
vm[type] = 'password'
vm.test = 'b'
})
.then(() => {
expect(vm.$el.type).toBe('password')
expect(vm.$el.value).toBe('b')
vm.$el.value = 'c'
triggerEvent(vm.$el, 'input')
expect(vm.test).toBe('c')
})
.then(() => {
// chang... | fim | vuejs/vue | typescript |
<|fim_suffix|> template: '<input v-model="file" type="file">'
}).$mount()
expect('Use a v-on:change listener instead').toHaveBeenWarned()
})
})
<|fim_prefix|>import Vue from 'vue'
describe('Directive v-model <|fim_middle|>file', () => {
it('warn to use @change instead', () => {
new Vue({
dat... | fim | vuejs/vue | typescript |
<|fim_suffix|>})
it('combined', () => {
const res = parseModel('test.xxx.a["asa"][test1[key]]')
expect(res.exp).toBe('test.xxx.a["asa"]')
expect(res.key).toBe('test1[key]')
})
})
<|fim_prefix|>import { parseModel } from 'compiler/directives/model'
describe('model expression parser', () => {
it('pars... | fim | vuejs/vue | typescript |
<|fim_suffix|>se)
vm.test = 2
waitForUpdate(() => {
expect(vm.$el.children[0].checked).toBe(false)
expect(vm.$el.children[1].checked).toBe(true)
vm.$el.children[0].click()
expect(vm.$el.children[0].checked).toBe(true)
expect(vm.$el.children[1].checked).toBe(false)
expect(vm.t... | fim | vuejs/vue | typescript |
<|fim_suffix|>rySelector('#false').multiple).toEqual(false)
expect(vm.$el.querySelector('#string').multiple).toEqual(true)
})
it('multiple with static template', () => {
const vm = new Vue({
template:
'<select multiple>' +
'<option selected>a</option>' +
'<option selected>b</o... | fim | vuejs/vue | typescript |
<|fim_suffix|> data: {
a: 'a'
},
template: '<input v-model="a" @input="onInput">',
methods: {
onInput(e) {
spy(e.target.value)
}
}
}).$mount()
expect(spy.mock.calls.length).toBe(0)
vm.$el.value = 'b'
triggerEvent(vm... | fim | vuejs/vue | typescript |
<|fim_suffix|> })
triggerEvent(vm.$refs.left, 'keydown', e => {
e.keyCode = 37
})
triggerEvent(vm.$refs.left, 'keydown', e => {
e.keyCode = 39
})
triggerEvent(vm.$refs.right, 'keydown', e => {
e.keyCode = 39
})
triggerEvent(vm.$refs.right, 'keydown', e => {
e.keyC... | fim | vuejs/vue | typescript |
<|fim_prefix|>import Vue from 'vue'
describe('Directive v-once', () => {
it('should not rerender component', done => {
const vm = new Vue({
template: '<div v-once>{{ a }}</div>',
data: { a: 'hello' }
}).$mount()
expect(vm.$el.innerHTML).toBe('hello')
vm.a = 'world'
waitForUpdate(() =>... | fim | vuejs/vue | typescript |
<|fim_suffix|>ile on root node', function () {
const vm = new Vue({
template: '<div v-pre>{{ a }}</div>',
replace: true,
data: {
a: 123
}
})
vm.$mount()
expect(vm.$el.firstChild.textContent).toBe('{{ a }}')
})
// #8286
it('should not compile custom component tags',... | fim | vuejs/vue | typescript |
<|fim_suffix|>e)
})
})
<|fim_prefix|>import Vue from 'vue'
describe('Directive v-show', () => {
it('should check show value is truthy', () => {
const vm = new Vue({
template: '<div><span v-show="foo">hello</span></div>',
data: { foo: true }
}).$mount()
expect(vm.$el.firstChild.style.display... | fim | vuejs/vue | typescript |
import { parseStyleText } from 'web/util/style'
const base64ImgUrl =
'url("data:image/webp;base64,UklGRkoAAABXRUJQVlA4WAoAAAAQAAAAAAAAAAAAQUxQSAwAAAARBxAR/Q9ERP8DAABWUDggGAAAABQBAJ0BKgEAAQAAAP4AAA3AAP7mtQAAAA==")'
const logoUrl = 'url(https://vuejs.org/images/logo.png)'
it('should parse normal static style', () => {... | fim | vuejs/vue | typescript |
<|fim_prefix|>import Vue from 'vue'
function checkPrefixedProp(prop) {
const el = document.createElement('div')
const upper = prop.charAt(0).toUpperCase() + prop.slice(1)
if (!(prop in el.style)) {
const prefixes = ['Webkit', 'Moz', 'ms']
let i = prefixes.length
while (i--) {
if (prefixes[i] + ... | fim | vuejs/vue | typescript |
<|fim_suffix|> .then(() => {
expect(vm.$el.innerHTML).toBe('foo')
vm.a = {
toJSON() {
return { foo: 'bar' }
}
}
})
.then(() => {
expect(vm.$el.innerHTML).toBe('{\n "foo": "bar"\n}')
vm.a = 123
})
.then(() => {
expe... | fim | vuejs/vue | typescript |
<|fim_suffix|>expect(vm.$el.textContent).toContain('error in render')
Vue.config.errorHandler = undefined
})
// event handlers that can throw errors or return rejected promise
;[
['single handler', '<div v-on:click="bork"></div>'],
[
'multiple handlers',
'<div v-on="{ click: [bork, functi... | fim | vuejs/vue | typescript |
<|fim_suffix|>iv>{{ msg | upper }}</div>',
data: { msg: 'foo' }
}).$mount()
expect('Failed to resolve filter: upper').toHaveBeenWarned()
})
it('support template string', () => {
expect(parseFilters('`a | ${b}c` | d')).toBe('_f("d")(`a | ${b}c`)')
})
it('bigint support', () => {
const vm ... | fim | vuejs/vue | typescript |
<|fim_suffix|> // extended registration should not pollute global
expect(Vue.options.components.test).toBeUndefined()
})
// #4434
it('local registration should take priority regardless of naming convention', () => {
Vue.component('x-foo', {
template: '<span>global</span>'
})
const vm = new... | fim | vuejs/vue | typescript |
<|fim_prefix|>import Vue from 'vue'
describe('Global API: compile', () => {
it('should compile render functions', () => {
const res = Vue.compile('<div><span>{{ msg }}</span></div>')
const vm = new Vue({
data: {
msg: 'hello'
},
<|fim_suffix|>mount()
expect(vm.$el.innerHTML).toConta... | fim | vuejs/vue | typescript |
<|fim_prefix|>import Vue from 'vue'
import { warn } from 'core/util/debug'
describe('Global config', () => {
it('should warn replacing config object', () => {
const originalConfig = Vue.config
Vue.config = {}
expect(Vue.config).toBe(originalConfig)
expect('Do not replace the Vue.config object').toHav... | fim | vuejs/vue | typescript |
<|fim_prefix|>import Vue from 'vue'
describe('Global API: extend', () => {
it('should correctly merge options', () => {
const Test = Vue.extend({
name: 'test',
a: 1,
b: 2
})
expect(Test.options.a).toBe(1)
expect(Test.options.b).toBe(2)
expect(<|fim_suffix|>
template: '... | fim | vuejs/vue | typescript |
<|fim_suffix|>ptions later
// vue-loader and vue-hot-reload-api are doing like this
Test.options.computed = {
$style: () => 123
}
const spy = vi.fn()
Test.options.beforeCreate = Test.options.beforeCreate.concat(spy)
// Update super constructor's options
const mixinSpy = vi.fn()
V... | fim | vuejs/vue | typescript |
<|fim_prefix|>import Vue from <|fim_suffix|>ble({
count: 0
})
const app = new Vue({
render(h) {
return h('div', [
h('span', state.count),
h(
'button',
{
on: {
click: () => {
state.count++
... | fim | vuejs/vue | typescript |
<|fim_prefix|>import Vue from 'vue'
describe('Global API: set/delete', () => {
describe('Vue.set', () => {
it('should update a vue object', done => {
const vm = new Vue({
template: '<div>{{x}}</div>',
data: { x: 1 }
}).$mount()
expect(vm.$el.innerHTML).toBe('1')
Vue.set(vm... | fim | vuejs/vue | typescript |
<|fim_prefix|>import Vue from 'vue'
describe('Global API: use', () => {
const def = {}
const options = {}
const pluginStub = {
install: (Vue, opts) => {
Vue.directive('plugin-test', def)
expect(opts).toBe(options)
}
}
it('should apply Object plugin', () => {
Vue.use(pluginStub, optio... | fim | vuejs/vue | typescript |
import Vue from 'vue'
describe('Initialization', () => {
it('without new', () => {
try {
Vue()
} catch (e) {}
expect(
'Vue is a constructor and should be called with the `new` keyword'
).toHaveBeenWarned()
})
it('with new', () => {
expect(new Vue() instanceof Vue).toBe(true)
})... | fim | vuejs/vue | typescript |
import Vue from 'vue'
describe('Instance methods data', () => {
it('$set/$delete', done => {
const vm = new Vue({
template: '<div>{{ a.msg }}</div>',
data: {
a: {}
}
}).$mount()
expect(vm.$el.innerHTML).toBe('')
vm.$set(vm.a, 'msg', 'hello')
waitForUpdate(() => {
e... | fim | vuejs/vue | typescript |
<|fim_suffix|>st', 1, 2, 3)
expect(spy).not.toHaveBeenCalled()
expect(spy2.mock.calls.length).toBe(1)
expect(spy2).toHaveBeenCalledWith(1, 2, 3)
})
})
<|fim_prefix|>import Vue from 'vue'
describe('Instance methods events', () => {
let vm, spy
beforeEach(() => {
vm = new Vue({})
spy = vi.fn()
... | fim | vuejs/vue | typescript |
<|fim_suffix|>
}
}
}
}).$mount()
})
it('Dep.target should be undefined during invocation of child immediate watcher', done => {
let calls = 0
const childData = { a: 1 }
const parentUpdate = vi.fn()
new Vue({
template: '<div><my-component></my-... | fim | vuejs/vue | typescript |
<|fim_prefix|>import Vue from 'vue'
describe('Instance properties', () => {
it('$data', () => {
const data = { a: 1 }
const vm = new Vue({
data
})
expect(vm.a).toBe(1)
expect(vm.$data).toBe(data)
// vm -> data
vm.a = 2
expect(data.a).toBe(2)
// data -> vm
data.a = 3
... | fim | vuejs/vue | typescript |
<|fim_suffix|>ym in this) {
return h('div', [this[sym]])
}
}
}).$mount()
expect(vm.$el.textContent).toBe('foo')
})
it('should warn properties starting with $ when found', () => {
new Vue({
data: { $a: 'foo' },
template: `<div>{{ $a }}</div>`
... | fim | vuejs/vue | typescript |
<|fim_suffix|>l not inherit parent scopeId
expect(el.hasAttribute('parent')).toBe(false)
})
})
})
<|fim_prefix|>import Vue from 'vue'
describe('Options _scopeId', () => {
it('should add scopeId attributes', () => {
const vm = new Vue({
_scopeId: 'foo',
template: '<div><p><span></span></p>... | fim | vuejs/vue | typescript |
<|fim_prefix|>import Vue from 'vue'
describe('Comments', () => {
it('comments should be kept', () => {
const vm = new Vue({
comments: true,
data() {<|fim_suffix|>>{{foo}}<!--comment2--></div>'
}).$mount()
expect(vm.$el.innerHTML).toEqual(
'<span>node1</span><!--comment1-->1<!--comment2-... | fim | vuejs/vue | typescript |
import Vue from 'vue'
import { UA } from 'core/util/env'
import testObjectOption from '../../../helpers/test-object-option'
describe('Options components', () => {
testObjectOption('components')
it('should accept plain object', () => {
const vm = new Vue({
template: '<test></test>',
components: {
... | fim | vuejs/vue | typescript |
<|fim_suffix|>d: {
// defined at instantiation
c() {
return this.b + 1
}
}
}).$mount()
expect(vm.b).toBe(2)
expect(vm.c).toBe(3)
expect(vm.$el.textContent).toBe('2 3')
vm.a = 2
expect(vm.b).toBe(3)
expect(vm.c).toBe(4)
waitForUpdate(() => {
e... | fim | vuejs/vue | typescript |
<|fim_suffix|>
render() {},
data() {
return {
b: this.a
}
}
}
const vm = new Vue({
template: `<test ref="test" :a="1"></test>`,
components: { Test }
}).$mount()
expect(vm.$refs.test.b).toBe(1)
})
it('props should not be reactive', done => {
... | fim | vuejs/vue | typescript |
<|fim_prefix|>import Vue from 'vue'
describe('Delimiters', () => {
it('default <|fim_suffix|>ustom delimiters should work', () => {
const vm = new Vue({
delimiters: ['[[', ']]'],
template: '<div>[[ a ]]</div>',
data: {
a: 1
}
}).$mount()
expect(vm.$el.textContent).toEqual... | fim | vuejs/vue | typescript |
<|fim_suffix|> }).$mount()
expect('Failed to resolve directive: test').toHaveBeenWarned()
})
// #6513
it('should invoke unbind & inserted on inner component root element change', done => {
const dir = {
bind: vi.fn(),
inserted: vi.fn(),
unbind: vi.fn()
}
const Child = {
... | fim | vuejs/vue | typescript |
<|fim_prefix|>import Vue from 'vue'
describe('Options el', () => {
it('basic usage', () => {
const el = document.createElement('div')
el.innerHTML = '<span>{{message}}</span>'
const vm = new Vue({
el,
data: { message: 'hello world' }
})
expect(vm.$el.tagName).toBe('DIV')
expect(vm... | fim | vuejs/vue | typescript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.