Skip to content

Commit 37491f7

Browse files
diogobedabenvinegar
authored andcommitted
Remove Vue.util.formatComponentName usage as it's not present on production (#848)
1 parent d1b8c5b commit 37491f7

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

plugins/vue.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@
44
*/
55
'use strict';
66

7+
function formatComponentName (vm) {
8+
if (vm.$root === vm) {
9+
return 'root instance'
10+
}
11+
var name = vm._isVue
12+
? vm.$options.name || vm.$options._componentTag
13+
: vm.name
14+
return (name ? 'component <' + name + '>' : 'anonymous component') +
15+
(vm._isVue && vm.$options.__file ? ' at ' + vm.$options.__file : '')
16+
}
17+
718
function vuePlugin(Raven, Vue) {
819
Vue = Vue || window.Vue;
920

@@ -14,7 +25,7 @@ function vuePlugin(Raven, Vue) {
1425
Vue.config.errorHandler = function VueErrorHandler(error, vm) {
1526
Raven.captureException(error, {
1627
extra: {
17-
componentName: Vue.util.formatComponentName(vm),
28+
componentName: formatComponentName(vm),
1829
propsData: vm.$options.propsData
1930
}
2031
});

test/plugins/vue.test.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,7 @@ describe('Vue plugin', function () {
1212
beforeEach(function () {
1313
this.sinon.stub(Raven, 'captureException');
1414
this.MockVue = {
15-
config: {},
16-
util: {
17-
formatComponentName: function() {
18-
return '<root component>'
19-
}
20-
}
15+
config: {}
2116
};
2217
});
2318

@@ -38,7 +33,7 @@ describe('Vue plugin', function () {
3833
propsData: {
3934
foo: 'bar'
4035
},
41-
componentName: '<root component>'
36+
componentName: 'anonymous component'
4237
});
4338
});
4439

0 commit comments

Comments
 (0)