File tree Expand file tree Collapse file tree 2 files changed +19
-13
lines changed Expand file tree Collapse file tree 2 files changed +19
-13
lines changed Original file line number Diff line number Diff line change 1
1
import clone from './clone.js' ;
2
2
import ctors from './constrators.js' ;
3
3
4
- function create ( tagName , Highcharts ) {
4
+ function create ( tagName , Highcharts , Vue ) {
5
5
var Ctor = Highcharts [ ctors [ tagName ] ] ;
6
6
if ( ! Ctor ) {
7
7
return null ;
8
8
}
9
9
var isRenderer = tagName === 'highcharts-renderer' ;
10
- return {
10
+ var component = {
11
11
name : tagName ,
12
- render : function ( createElement ) {
13
- return createElement ( 'div' ) ;
14
- } ,
15
12
props : isRenderer
16
13
? {
17
14
width : { type : Number , required : true } ,
@@ -37,9 +34,6 @@ function create(tagName, Highcharts) {
37
34
}
38
35
}
39
36
} ,
40
- mounted : function ( ) {
41
- this . _initChart ( ) ;
42
- } ,
43
37
beforeDestroy : function ( ) {
44
38
if ( isRenderer ) {
45
39
this . $el . removeChild ( this . renderer . box ) ;
@@ -50,12 +44,24 @@ function create(tagName, Highcharts) {
50
44
} else {
51
45
this . chart . destroy ( ) ;
52
46
}
53
- } ,
54
- // compat Vue v1.x
55
- ready : function ( ) {
56
- this . _initChart ( ) ;
57
47
}
58
48
} ;
49
+ var isVue1 = / ^ 1 \. / . test ( Vue . version ) ;
50
+ if ( isVue1 ) {
51
+ component . template = '<div></div>' ;
52
+ component . ready = function ( ) {
53
+ this . _initChart ( ) ;
54
+ } ;
55
+ } else {
56
+ component . render = function ( createElement ) {
57
+ return createElement ( 'div' ) ;
58
+ } ;
59
+ component . mounted = function ( ) {
60
+ this . _initChart ( ) ;
61
+ } ;
62
+ }
63
+ return component ;
59
64
}
60
65
61
66
export default create ;
67
+
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ function install(Vue, options) {
6
6
var Highcharts = ( options && options . Highcharts ) || HighchartsOnly ;
7
7
Vue . prototype . Highcharts = Highcharts ;
8
8
for ( var tagName in ctors ) {
9
- var component = create ( tagName , Highcharts ) ;
9
+ var component = create ( tagName , Highcharts , Vue ) ;
10
10
component && Vue . component ( tagName , component ) ;
11
11
}
12
12
}
You can’t perform that action at this time.
0 commit comments