@@ -40,6 +40,8 @@ export type HighlightOptions = {
40
40
} ;
41
41
42
42
export class Highlight {
43
+ private _dialogElement : HTMLDialogElement ;
44
+ private _dialogStyles : HTMLStyleElement ;
43
45
private _glassPaneElement : HTMLElement ;
44
46
private _glassPaneShadow : ShadowRoot ;
45
47
private _highlightEntries : HighlightEntry [ ] = [ ] ;
@@ -54,6 +56,19 @@ export class Highlight {
54
56
this . _injectedScript = injectedScript ;
55
57
const document = injectedScript . document ;
56
58
this . _isUnderTest = injectedScript . isUnderTest ;
59
+ this . _dialogStyles = document . createElement ( 'style' ) ;
60
+ this . _dialogStyles . textContent = `
61
+ dialog#pw-dialog::backdrop {
62
+ background-color: transparent;
63
+ }
64
+ ` ;
65
+ this . _dialogElement = document . createElement ( 'dialog' ) ;
66
+ this . _dialogElement . id = 'pw-dialog' ;
67
+ this . _dialogElement . style . padding = '0' ;
68
+ this . _dialogElement . style . margin = '0' ;
69
+ this . _dialogElement . style . border = 'none' ;
70
+ this . _dialogElement . style . maxWidth = 'inherit' ;
71
+ this . _dialogElement . style . maxHeight = 'inherit' ;
57
72
this . _glassPaneElement = document . createElement ( 'x-pw-glass' ) ;
58
73
this . _glassPaneElement . style . position = 'fixed' ;
59
74
this . _glassPaneElement . style . top = '0' ;
@@ -64,6 +79,7 @@ export class Highlight {
64
79
this . _glassPaneElement . style . pointerEvents = 'none' ;
65
80
this . _glassPaneElement . style . display = 'flex' ;
66
81
this . _glassPaneElement . style . backgroundColor = 'transparent' ;
82
+ this . _dialogElement . appendChild ( this . _glassPaneElement ) ;
67
83
for ( const eventName of [ 'click' , 'auxclick' , 'dragstart' , 'input' , 'keydown' , 'keyup' , 'pointerdown' , 'pointerup' , 'mousedown' , 'mouseup' , 'mouseleave' , 'focus' , 'scroll' ] ) {
68
84
this . _glassPaneElement . addEventListener ( eventName , e => {
69
85
e . stopPropagation ( ) ;
@@ -82,7 +98,9 @@ export class Highlight {
82
98
}
83
99
84
100
install ( ) {
85
- this . _injectedScript . document . documentElement . appendChild ( this . _glassPaneElement ) ;
101
+ this . _injectedScript . document . documentElement . appendChild ( this . _dialogStyles ) ;
102
+ this . _injectedScript . document . documentElement . appendChild ( this . _dialogElement ) ;
103
+ this . _dialogElement . showModal ( ) ;
86
104
}
87
105
88
106
setLanguage ( language : Language ) {
@@ -99,7 +117,9 @@ export class Highlight {
99
117
uninstall ( ) {
100
118
if ( this . _rafRequest )
101
119
cancelAnimationFrame ( this . _rafRequest ) ;
102
- this . _glassPaneElement . remove ( ) ;
120
+ this . _dialogElement . close ( ) ;
121
+ this . _dialogElement . remove ( ) ;
122
+ this . _dialogStyles . remove ( ) ;
103
123
}
104
124
105
125
showActionPoint ( x : number , y : number ) {
@@ -127,7 +147,7 @@ export class Highlight {
127
147
}
128
148
129
149
maskElements ( elements : Element [ ] , color : string ) {
130
- this . _innerUpdateHighlight ( elements , { color : color } ) ;
150
+ this . _innerUpdateHighlight ( elements , { color } ) ;
131
151
}
132
152
133
153
private _innerUpdateHighlight ( elements : Element [ ] , options : HighlightOptions ) {
0 commit comments