Skip to content

Commit a102b1b

Browse files
committed
Change to have single root elm for service injector html elms
1 parent c518620 commit a102b1b

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

injector.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767

6868
var injector = {
6969
state : {
70+
root: null,
7071
win: null,
7172
winPosition: {
7273
top: 0,
@@ -141,12 +142,17 @@
141142
styleElm.innerHTML = injectorStyles;
142143
document.getElementsByTagName('head')[0].appendChild(styleElm);
143144

145+
var rootElm = document.createElement('div');
146+
rootElm.setAttribute("id", sp("%prefix%-service-injector"));
147+
document.body.appendChild(rootElm);
148+
injector.state.root = rootElm;
149+
144150
var shadowElm = document.createElement('div');
145151
shadowElm.setAttribute("id", sp("%prefix%-shadow"));
146152
shadowElm.style.position = 'fixed';
147153
shadowElm.style.display = 'none';
148154
shadowElm.style['z-index'] = 99997;
149-
document.body.appendChild(shadowElm);
155+
rootElm.appendChild(shadowElm);
150156
injector.state.shadow = shadowElm;
151157

152158
var tabElm = document.createElement('div');
@@ -156,7 +162,7 @@
156162
tabElm.style[conf.p] = '0px';
157163
tabElm.style[offsetOrientation[conf.p]] = conf.o;
158164
tabElm.style['z-index'] = 99998;
159-
document.body.appendChild(tabElm);
165+
rootElm.appendChild(tabElm);
160166
injector.state.tab = tabElm;
161167

162168
var winElm = document.createElement('div');
@@ -173,7 +179,7 @@
173179
if(conf.wl) winElm.style.left = conf.wl;
174180
if(conf.wr) winElm.style.right = conf.wr;
175181
winElm.style['z-index'] = 99999;
176-
document.body.appendChild(winElm);
182+
rootElm.appendChild(winElm);
177183
injector.state.win = winElm;
178184
if( typeof conf.wc != 'undefined') {
179185
winElm.style.left = ((screen.width - winElm.offsetWidth+conf.wc) / 2)+"px";

0 commit comments

Comments
 (0)