angular/devtools/projects/shell-browser/src/app/ng-validate.ts
Matthieu Riegler f8f8928210 fix(devtools): prevent devTools to load when not text/html document (#48021)
On Firefox, Angular DevTools was breaking the XML display because of the script injected
Based on contentType, we won't inject that script anymore

Fixes #48017

PR Close #48021
2022-11-17 09:35:40 -08:00

22 lines
680 B
TypeScript

/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/// <reference types="chrome"/>
window.addEventListener('message', (event: MessageEvent) => {
if (event.source === window && event.data) {
chrome.runtime.sendMessage(event.data);
}
});
if (document.contentType === 'text/html') {
const script = document.createElement('script');
script.src = chrome.runtime.getURL('app/detect_angular_for_extension_icon_bundle.js');
document.documentElement.appendChild(script);
document.documentElement.removeChild(script);
}