A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/vuejs/vue/commit/01151ce3fa3cb346443d086332ec053c389ee619 below:

fix #4872, use context agnostic Function constructor check (#4928) · vuejs/vue@01151ce · GitHub

File tree Expand file treeCollapse file tree 3 files changed

+36

-1

lines changed

Filter options

Expand file treeCollapse file tree 3 files changed

+36

-1

lines changed Original file line number Diff line number Diff line change

@@ -70,7 +70,8 @@ function getPropDefaultValue (vm: ?Component, prop: PropOptions, key: string): a

70 70

return vm._props[key]

71 71

}

72 72

// call factory function for non-Function types

73 -

return typeof def === 'function' && prop.type !== Function

73 +

// a value is Function if its prototype is function even across different execution context

74 +

return typeof def === 'function' && getType(prop.type) !== 'Function'

74 75

? def.call(vm)

75 76

: def

76 77

}

Original file line number Diff line number Diff line change

@@ -1,4 +1,5 @@

1 1

import Vue from '../../dist/vue.runtime.common.js'

2 +

import VM from 'vm'

2 3

import { createRenderer } from '../../packages/vue-server-renderer'

3 4

const { renderToString } = createRenderer()

4 5

@@ -699,6 +700,23 @@ describe('SSR: renderToString', () => {

699 700

done()

700 701

}, context)

701 702

})

703 + 704 +

it('default value Foreign Function', () => {

705 +

const FunctionConstructor = VM.runInNewContext('Function')

706 +

const func = () => 123

707 +

const vm = new Vue({

708 +

props: {

709 +

a: {

710 +

type: FunctionConstructor,

711 +

default: func

712 +

}

713 +

},

714 +

propsData: {

715 +

a: undefined

716 +

}

717 +

})

718 +

expect(vm.a).toBe(func)

719 +

})

702 720

})

703 721 704 722

function renderVmWithOptions (options, cb) {

Original file line number Diff line number Diff line change

@@ -98,6 +98,22 @@ describe('Options props', () => {

98 98

}).then(done)

99 99

})

100 100 101 +

it('default value Function', () => {

102 +

const func = () => 132

103 +

const vm = new Vue({

104 +

props: {

105 +

a: {

106 +

type: Function,

107 +

default: func

108 +

}

109 +

},

110 +

propsData: {

111 +

a: undefined

112 +

}

113 +

})

114 +

expect(vm.a).toBe(func)

115 +

})

116 + 101 117

it('warn object/array default values', () => {

102 118

new Vue({

103 119

props: {

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4