A RetroSearch Logo

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

Search Query:

Showing content from https://github.com/vuejs/vue-next/commit/ce0bbe053abaf8ba18de8baf535e175048596ee5 below:

support component-level `compilerOptions` when using runtime co… · vuejs/core@ce0bbe0 · GitHub

1 +

import { createApp } from 'vue'

2 + 3 +

describe('config.compilerOptions', () => {

4 +

test('isCustomElement', () => {

5 +

const app = createApp({

6 +

template: `<foo/>`

7 +

})

8 +

app.config.compilerOptions.isCustomElement = (tag: string) => tag === 'foo'

9 +

const root = document.createElement('div')

10 +

app.mount(root)

11 +

expect(root.innerHTML).toBe('<foo></foo>')

12 +

})

13 + 14 +

test('comments', () => {

15 +

const app = createApp({

16 +

template: `<div/><!--test--><div/>`

17 +

})

18 +

app.config.compilerOptions.comments = true

19 +

// the comments option is only relevant in production mode

20 +

__DEV__ = false

21 +

const root = document.createElement('div')

22 +

app.mount(root)

23 +

expect(root.innerHTML).toBe('<div></div><!--test--><div></div>')

24 +

__DEV__ = true

25 +

})

26 + 27 +

test('whitespace', () => {

28 +

const app = createApp({

29 +

template: `<div><span/>\n <span/></div>`

30 +

})

31 +

app.config.compilerOptions.whitespace = 'preserve'

32 +

const root = document.createElement('div')

33 +

app.mount(root)

34 +

expect(root.firstChild!.childNodes.length).toBe(3)

35 +

expect(root.firstChild!.childNodes[1].nodeType).toBe(Node.TEXT_NODE)

36 +

})

37 + 38 +

test('delimiters', () => {

39 +

const app = createApp({

40 +

data: () => ({ foo: 'hi' }),

41 +

template: `[[ foo ]]`

42 +

})

43 +

app.config.compilerOptions.delimiters = [`[[`, `]]`]

44 +

const root = document.createElement('div')

45 +

app.mount(root)

46 +

expect(root.textContent).toBe('hi')

47 +

})

48 +

})

49 + 50 +

describe('per-component compilerOptions', () => {

51 +

test('isCustomElement', () => {

52 +

const app = createApp({

53 +

template: `<foo/>`,

54 +

compilerOptions: {

55 +

isCustomElement: (tag: string) => tag === 'foo'

56 +

}

57 +

})

58 +

const root = document.createElement('div')

59 +

app.mount(root)

60 +

expect(root.innerHTML).toBe('<foo></foo>')

61 +

})

62 + 63 +

test('comments', () => {

64 +

const app = createApp({

65 +

template: `<div/><!--test--><div/>`,

66 +

compilerOptions: {

67 +

comments: true

68 +

}

69 +

})

70 +

app.config.compilerOptions.comments = false

71 +

// the comments option is only relevant in production mode

72 +

__DEV__ = false

73 +

const root = document.createElement('div')

74 +

app.mount(root)

75 +

expect(root.innerHTML).toBe('<div></div><!--test--><div></div>')

76 +

__DEV__ = true

77 +

})

78 + 79 +

test('whitespace', () => {

80 +

const app = createApp({

81 +

template: `<div><span/>\n <span/></div>`,

82 +

compilerOptions: {

83 +

whitespace: 'preserve'

84 +

}

85 +

})

86 +

const root = document.createElement('div')

87 +

app.mount(root)

88 +

expect(root.firstChild!.childNodes.length).toBe(3)

89 +

expect(root.firstChild!.childNodes[1].nodeType).toBe(Node.TEXT_NODE)

90 +

})

91 + 92 +

test('delimiters', () => {

93 +

const app = createApp({

94 +

data: () => ({ foo: 'hi' }),

95 +

template: `[[ foo ]]`,

96 +

compilerOptions: {

97 +

delimiters: [`[[`, `]]`]

98 +

}

99 +

})

100 +

const root = document.createElement('div')

101 +

app.mount(root)

102 +

expect(root.textContent).toBe('hi')

103 +

})

104 +

})


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