File tree Expand file tree Collapse file tree 2 files changed +17
-3
lines changed Expand file tree Collapse file tree 2 files changed +17
-3
lines changed Original file line number Diff line number Diff line change 33
33
import { mapState , mapGetters , mapMutations } from ' vuex'
34
34
import CompDef from ' ./Other.vue'
35
35
36
+ function setToString (func , string ) {
37
+ return Object .defineProperty (func, ' toString' , {
38
+ configurable: true ,
39
+ enumerable: false ,
40
+ value : () => string,
41
+ writable: true
42
+ })
43
+ }
44
+
45
+ const aWeirdFunction = setToString (function weird (a , b , c ) {}, ' foo' )
46
+
36
47
export default {
37
48
components: {
38
49
TestComponent: {
@@ -53,6 +64,7 @@ export default {
53
64
hello : function foo (a , b , c ) {},
54
65
hey : function empty () {},
55
66
anon : function (foo , bar ) {},
67
+ aWeirdFunction,
56
68
arrow : (a , b ) => {},
57
69
def: CompDef,
58
70
def2: {
Original file line number Diff line number Diff line change @@ -117,9 +117,9 @@ function replacer (key) {
117
117
return encodeCache . cache ( val , ( ) => getCustomSetDetails ( val ) )
118
118
} else if ( val instanceof RegExp ) {
119
119
// special handling of native type
120
- return `[native RegExp ${ val . toString ( ) } ]`
120
+ return `[native RegExp ${ RegExp . prototype . toString . call ( val ) } ]`
121
121
} else if ( val instanceof Date ) {
122
- return `[native Date ${ val . toString ( ) } ]`
122
+ return `[native Date ${ Date . prototype . toString . call ( val ) } ]`
123
123
} else if ( val . state && val . _vm ) {
124
124
return encodeCache . cache ( val , ( ) => getCustomStoreDetails ( val ) )
125
125
} else if ( val . constructor && val . constructor . name === 'VueRouter' ) {
@@ -230,7 +230,9 @@ export function getCustomComponentDefinitionDetails (def) {
230
230
}
231
231
232
232
export function getCustomFunctionDetails ( func ) {
233
- const args = func . toString ( ) . match ( / \( .* \) / ) [ 0 ]
233
+ const string = Function . prototype . toString . call ( func ) || ''
234
+ const matches = string . match ( / \( .* \) / )
235
+ const args = matches ? matches [ 0 ] : '(?)'
234
236
return {
235
237
_custom : {
236
238
type : 'function' ,
You can’t perform that action at this time.
0 commit comments