@@ -35,17 +35,14 @@ function clone(obj) {
35
35
}
36
36
}
37
37
38
- function create ( tagName , Highcharts ) {
38
+ function create ( tagName , Highcharts , Vue ) {
39
39
var Ctor = Highcharts [ ctors [ tagName ] ] ;
40
40
if ( ! Ctor ) {
41
41
return null ;
42
42
}
43
43
var isRenderer = tagName === 'highcharts-renderer' ;
44
- return {
44
+ var component = {
45
45
name : tagName ,
46
- render : function ( createElement ) {
47
- return createElement ( 'div' ) ;
48
- } ,
49
46
props : isRenderer
50
47
? {
51
48
width : { type : Number , required : true } ,
@@ -71,9 +68,6 @@ function create(tagName, Highcharts) {
71
68
}
72
69
}
73
70
} ,
74
- mounted : function ( ) {
75
- this . _initChart ( ) ;
76
- } ,
77
71
beforeDestroy : function ( ) {
78
72
if ( isRenderer ) {
79
73
this . $el . removeChild ( this . renderer . box ) ;
@@ -84,19 +78,30 @@ function create(tagName, Highcharts) {
84
78
} else {
85
79
this . chart . destroy ( ) ;
86
80
}
87
- } ,
88
- // compat Vue v1.x
89
- ready : function ( ) {
90
- this . _initChart ( ) ;
91
81
}
92
82
} ;
83
+ var isVue1 = / ^ 1 \. / . test ( Vue . version ) ;
84
+ if ( isVue1 ) {
85
+ component . template = '<div></div>' ;
86
+ component . ready = function ( ) {
87
+ this . _initChart ( ) ;
88
+ } ;
89
+ } else {
90
+ component . render = function ( createElement ) {
91
+ return createElement ( 'div' ) ;
92
+ } ;
93
+ component . mounted = function ( ) {
94
+ this . _initChart ( ) ;
95
+ } ;
96
+ }
97
+ return component ;
93
98
}
94
99
95
100
function install ( Vue , options ) {
96
101
var Highcharts = ( options && options . Highcharts ) || HighchartsOnly ;
97
102
Vue . prototype . Highcharts = Highcharts ;
98
103
for ( var tagName in ctors ) {
99
- var component = create ( tagName , Highcharts ) ;
104
+ var component = create ( tagName , Highcharts , Vue ) ;
100
105
component && Vue . component ( tagName , component ) ;
101
106
}
102
107
}
0 commit comments