forked from vuejs/devtools-v6
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNativeTypes.vue
More file actions
158 lines (134 loc) · 3.24 KB
/
NativeTypes.vue
File metadata and controls
158 lines (134 loc) · 3.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
<template>
<div id="native-types">
<TestComponent ref="component" />
<div
id="aDiv"
ref="someDiv"
class="foo bar"
data-testid="some-div"
/>
<p>
<button
style="background: red; color: white;"
@click="createLargeArray()"
>
Create large array
</button>
</p>
<p>
Large array size: {{ largeArray.length }}
</p>
<h3>Set</h3>
<pre>{{ setDisplay() }}</pre>
<h3>Map</h3>
<pre>{{ mapDisplay() }}</pre>
</div>
</template>
<script>
/* eslint-disable @typescript-eslint/no-empty-function */
import { h } from 'vue'
import CompDef from './Other.vue'
function setToString (func, string) {
return Object.defineProperty(func, 'toString', {
configurable: true,
enumerable: false,
value: () => string,
writable: true,
})
}
const aWeirdFunction = setToString(function weird (a, b, c) {}, 'foo')
function sum (a, b) {
return a + b
}
const handler = {
apply: function (target, thisArg, argumentsList) {
console.log(`Calculate sum: ${argumentsList}`)
return argumentsList[0] + argumentsList[1]
},
}
const proxy1 = new Proxy(sum, handler)
let veryLongText = ''
for (let i = 0; i < 1000000; i++) {
veryLongText += `line${i}\n`
}
export default {
components: {
TestComponent: {
props: { bar: { default: 'hey' } },
data: () => ({ foo: '42' }),
computed: {
parentComp () { return this.$parent },
},
render: () => h('div', '<TestComponent />'),
},
},
props: {
multiTypeProp: {
type: [Date, Boolean],
default: false,
},
},
data () {
return {
localDate: new Date(),
reg: /abc/gi,
testComponent: null,
hello: function foo (a, b, c) {},
hey: function empty () {},
anon: function (foo, bar) {},
aWeirdFunction,
arrow: (a, b) => {},
def: CompDef,
def2: {
name: 'MyComponent',
render () {},
},
def3: {
render () {},
},
largeArray: [],
i: new Set([1, 2, 3, 4, new Set([5, 6, 7, 8]), new Map([[1, 2], [3, 4], [5, new Map([[6, 7]])]])]),
j: new Map([[1, 2], [3, 4], [5, new Map([[6, 7]])], [8, new Set([1, 2, 3, 4, new Set([5, 6, 7, 8]), new Map([[1, 2], [3, 4], [5, new Map([[6, 7]])]])])]]),
html: '<b>Bold</b> <i>Italic</i>',
htmlReg: /<b>hey<\/b>/i,
'html <b>key</b>': (h, t, m, l) => {},
proxy1,
sym: Symbol('test'),
multiLineParameterFunction: function (a,
b,
c) {},
veryLongText,
someElement: null,
}
},
computed: {
// eslint-disable-next-line vue/return-in-computed-property
throws () {
throw new Error('Some error')
},
},
mounted () {
this.testComponent = this.$refs.component
this.someElement = this.$refs.someDiv
},
methods: {
createLargeArray () {
const list = []
for (let i = 0; i < 10000000; i++) {
list.push(i)
}
this.largeArray = list
},
setDisplay () {
if (this.set) return Array.from(this.set)
},
mapDisplay () {
if (this.map) return [...this.map]
},
forceRefresh () {
this.$forceUpdate()
},
prototypeString: val => Object.prototype.toString.call(val),
},
}
</script>