A RetroSearch Logo

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

Search Query:

Showing content from https://github.com/vuejs/vue/commit/0e4e45ec741416e0042c29a53bbc0e58c8663f6e below:

support custom toString() in text interpolation and v-html (#8217) · vuejs/vue@0e4e45e · GitHub

File tree Expand file treeCollapse file tree 3 files changed

+13

-1

lines changed

Filter options

Expand file treeCollapse file tree 3 files changed

+13

-1

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

@@ -85,7 +85,7 @@ export function isPromise (val: any): boolean {

85 85

export function toString (val: any): string {

86 86

return val == null

87 87

? ''

88 -

: typeof val === 'object'

88 +

: Array.isArray(val) || (isPlainObject(val) && val.toString === _toString)

89 89

? JSON.stringify(val, null, 2)

90 90

: String(val)

91 91

}

Original file line number Diff line number Diff line change

@@ -44,6 +44,12 @@ describe('Directive v-html', () => {

44 44

vm.a = {}

45 45

}).then(() => {

46 46

expect(vm.$el.innerHTML).toBe('{}')

47 +

vm.a = { toString () { return 'foo' } }

48 +

}).then(() => {

49 +

expect(vm.$el.innerHTML).toBe('foo')

50 +

vm.a = { toJSON () { return { foo: 'bar' } } }

51 +

}).then(() => {

52 +

expect(vm.$el.innerHTML).toBe('{\n "foo": "bar"\n}')

47 53

vm.a = 123

48 54

}).then(() => {

49 55

expect(vm.$el.innerHTML).toBe('123')

Original file line number Diff line number Diff line change

@@ -30,6 +30,12 @@ describe('Directive v-text', () => {

30 30

vm.a = {}

31 31

}).then(() => {

32 32

expect(vm.$el.innerHTML).toBe('{}')

33 +

vm.a = { toString () { return 'foo' } }

34 +

}).then(() => {

35 +

expect(vm.$el.innerHTML).toBe('foo')

36 +

vm.a = { toJSON () { return { foo: 'bar' } } }

37 +

}).then(() => {

38 +

expect(vm.$el.innerHTML).toBe('{\n "foo": "bar"\n}')

33 39

vm.a = 123

34 40

}).then(() => {

35 41

expect(vm.$el.innerHTML).toBe('123')

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