@volo/ngx-lepton-x.core 4.3.0-rc.3 → 4.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -205,29 +205,34 @@ class StyleService {
|
|
|
205
205
|
this.initialized$ = new BehaviorSubject(false);
|
|
206
206
|
}
|
|
207
207
|
async initStyles(direction) {
|
|
208
|
+
const cssExtension = direction === 'rtl' ? '.rtl' : '';
|
|
208
209
|
for (const style of this.initialStyles) {
|
|
210
|
+
const href = `${style.bundleName}${cssExtension}.css`;
|
|
211
|
+
const selector = `
|
|
212
|
+
link[rel="stylesheet"][href$="${href}"],
|
|
213
|
+
link[rel="stylesheet"]#${style.bundleName}
|
|
214
|
+
`;
|
|
215
|
+
const isAlreadyLoaded = !!this.document.querySelector(selector);
|
|
216
|
+
if (isAlreadyLoaded) {
|
|
217
|
+
continue;
|
|
218
|
+
}
|
|
209
219
|
await this.loadStyle(style, direction);
|
|
210
220
|
}
|
|
211
221
|
this.initialized$.next(true);
|
|
212
222
|
}
|
|
213
223
|
async loadStyle(style, direction) {
|
|
214
|
-
return new Promise((resolve
|
|
215
|
-
const
|
|
216
|
-
|
|
217
|
-
const
|
|
218
|
-
if (
|
|
219
|
-
|
|
220
|
-
this.lastInjectedStyle.insertAdjacentElement('afterend', linkElem);
|
|
221
|
-
}
|
|
222
|
-
else {
|
|
223
|
-
appStyles.insertAdjacentElement('beforebegin', linkElem);
|
|
224
|
-
}
|
|
224
|
+
return new Promise((resolve) => {
|
|
225
|
+
const linkElement = this.createLinkElem(style, direction, resolve);
|
|
226
|
+
const styleLinks = Array.from(this.document.head.querySelectorAll('link[rel="stylesheet"]'));
|
|
227
|
+
const lastStyleLink = styleLinks[styleLinks.length - 1];
|
|
228
|
+
if (lastStyleLink) {
|
|
229
|
+
lastStyleLink.insertAdjacentElement('afterend', linkElement);
|
|
225
230
|
}
|
|
226
231
|
else {
|
|
227
|
-
this.document.head.appendChild(
|
|
232
|
+
this.document.head.appendChild(linkElement);
|
|
228
233
|
}
|
|
229
|
-
this.lastInjectedStyle =
|
|
230
|
-
|
|
234
|
+
this.lastInjectedStyle = linkElement;
|
|
235
|
+
resolve(linkElement);
|
|
231
236
|
});
|
|
232
237
|
}
|
|
233
238
|
async replaceStyle(style, direction) {
|