File tree 3 files changed +31
-10
lines changed 3 files changed +31
-10
lines changed Original file line number Diff line number Diff line change 1
- import { createApp } from 'vue' ;
2
1
import ContextPopup from '../components/ContextPopup.vue' ;
2
+ import { createVueRoot } from '../utils/vue.js' ;
3
3
import { parseIssueHref } from '../utils.js' ;
4
4
import { createTippy } from '../modules/tippy.js' ;
5
5
import { GET } from '../modules/fetch.js' ;
@@ -20,19 +20,13 @@ async function show(e) {
20
20
} catch { }
21
21
if ( ! issue ) return ;
22
22
23
- const popup = document . createElement ( 'div' ) ;
24
- const view = createApp ( ContextPopup , { issue, labelsHtml} ) ;
25
- try {
26
- view . mount ( popup ) ;
27
- } catch ( err ) {
28
- console . error ( err ) ;
29
- return ;
30
- }
23
+ const content = createVueRoot ( ContextPopup , { issue, labelsHtml} ) ;
24
+ if ( ! content ) return ;
31
25
32
26
const tippy = createTippy ( link , {
33
27
theme : 'default' ,
34
28
trigger : 'mouseenter focus' ,
35
- content : popup ,
29
+ content,
36
30
placement : 'top-start' ,
37
31
interactive : true ,
38
32
role : 'dialog' ,
Original file line number Diff line number Diff line change @@ -297,3 +297,16 @@ export function replaceTextareaSelection(textarea, text) {
297
297
textarea . dispatchEvent ( new CustomEvent ( 'change' , { bubbles : true , cancelable : true } ) ) ;
298
298
}
299
299
}
300
+
301
+ //
302
+ function createVueElement ( Component , rootProps ) {
303
+ const container = document . createElement ( 'div' ) ;
304
+ const view = createApp ( Component , rootProps ) ;
305
+ try {
306
+ view . mount ( container ) ;
307
+ return container ;
308
+ } catch ( err ) {
309
+ console . error ( err ) ;
310
+ return null ;
311
+ }
312
+ }
Original file line number Diff line number Diff line change
1
+ import { createApp } from 'vue' ;
2
+
3
+ // create a new vue root and container and mount a component into it
4
+ export function createVueRoot ( component , rootProps ) {
5
+ const container = document . createElement ( 'div' ) ;
6
+ const view = createApp ( component , rootProps ) ;
7
+ try {
8
+ view . mount ( container ) ;
9
+ return container ;
10
+ } catch ( err ) {
11
+ console . error ( err ) ;
12
+ return null ;
13
+ }
14
+ }
You can’t perform that action at this time.
0 commit comments