|
@@ -48,22 +48,27 @@ export class Inspector {
|
|
|
private static _CopyStyles(sourceDoc: HTMLDocument, targetDoc: HTMLDocument) {
|
|
|
for (var index = 0; index < sourceDoc.styleSheets.length; index++) {
|
|
|
var styleSheet: any = sourceDoc.styleSheets[index];
|
|
|
- if (styleSheet.cssRules) { // for <style> elements
|
|
|
- const newStyleEl = sourceDoc.createElement('style');
|
|
|
-
|
|
|
- for (var cssRule of styleSheet.cssRules) {
|
|
|
- // write the text of each rule into the body of the style element
|
|
|
- newStyleEl.appendChild(sourceDoc.createTextNode(cssRule.cssText));
|
|
|
+ try{
|
|
|
+ if (styleSheet.cssRules) { // for <style> elements
|
|
|
+ const newStyleEl = sourceDoc.createElement('style');
|
|
|
+
|
|
|
+ for (var cssRule of styleSheet.cssRules) {
|
|
|
+ // write the text of each rule into the body of the style element
|
|
|
+ newStyleEl.appendChild(sourceDoc.createTextNode(cssRule.cssText));
|
|
|
+ }
|
|
|
+
|
|
|
+ targetDoc.head!.appendChild(newStyleEl);
|
|
|
+ } else if (styleSheet.href) { // for <link> elements loading CSS from a URL
|
|
|
+ const newLinkEl = sourceDoc.createElement('link');
|
|
|
+
|
|
|
+ newLinkEl.rel = 'stylesheet';
|
|
|
+ newLinkEl.href = styleSheet.href;
|
|
|
+ targetDoc.head!.appendChild(newLinkEl);
|
|
|
}
|
|
|
-
|
|
|
- targetDoc.head!.appendChild(newStyleEl);
|
|
|
- } else if (styleSheet.href) { // for <link> elements loading CSS from a URL
|
|
|
- const newLinkEl = sourceDoc.createElement('link');
|
|
|
-
|
|
|
- newLinkEl.rel = 'stylesheet';
|
|
|
- newLinkEl.href = styleSheet.href;
|
|
|
- targetDoc.head!.appendChild(newLinkEl);
|
|
|
+ }catch(e){
|
|
|
+ console.log(e)
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|