test(core): update Web Platform feature detection (#24861)
PR Close #24861
This commit is contained in:

committed by
Misko Hevery

parent
6e6489a408
commit
d76a7d6f7c
@ -87,8 +87,7 @@ import {NAMESPACE_URIS} from '../../src/dom/dom_renderer';
|
||||
});
|
||||
});
|
||||
|
||||
// other browsers don't support shadow dom
|
||||
if (browserDetection.isChromeDesktop) {
|
||||
if (browserDetection.supportsDeprecatedShadowDomV0) {
|
||||
it('should allow to style components with emulated encapsulation and no encapsulation inside of components with shadow DOM',
|
||||
() => {
|
||||
const fixture = TestBed.createComponent(SomeApp);
|
||||
|
@ -9,14 +9,11 @@
|
||||
import {Component, EventEmitter, Injector, Input, NgModule, Output, Renderer2, ViewEncapsulation, destroyPlatform} from '@angular/core';
|
||||
import {TestBed} from '@angular/core/testing';
|
||||
import {BrowserModule} from '@angular/platform-browser';
|
||||
import {browserDetection} from '@angular/platform-browser/testing/src/browser_util';
|
||||
import {expect} from '@angular/platform-browser/testing/src/matchers';
|
||||
|
||||
function supportsShadowDOMV1() {
|
||||
const testEl = document.createElement('div');
|
||||
return (typeof customElements !== 'undefined') && (typeof testEl.attachShadow !== 'undefined');
|
||||
}
|
||||
|
||||
if (supportsShadowDOMV1()) {
|
||||
if (browserDetection.supportsShadowDom) {
|
||||
describe('ShadowDOM Support', () => {
|
||||
|
||||
let testContainer: HTMLDivElement;
|
||||
|
@ -68,6 +68,23 @@ export class BrowserDetection {
|
||||
return this._ua.indexOf('Chrome') > -1 && this._ua.indexOf('Chrome/3') > -1 &&
|
||||
this._ua.indexOf('Edge') == -1;
|
||||
}
|
||||
|
||||
get supportsCustomElements() { return (typeof(<any>global).customElements !== 'undefined'); }
|
||||
|
||||
get supportsDeprecatedCustomCustomElementsV0() {
|
||||
return (typeof(document as any).registerElement !== 'undefined');
|
||||
}
|
||||
|
||||
get supportsShadowDom() {
|
||||
const testEl = document.createElement('div');
|
||||
return (typeof customElements !== 'undefined') && (typeof testEl.attachShadow !== 'undefined');
|
||||
}
|
||||
|
||||
get supportsDeprecatedShadowDomV0() {
|
||||
const testEl = document.createElement('div') as any;
|
||||
return (typeof customElements !== 'undefined') &&
|
||||
(typeof testEl.createShadowRoot !== 'undefined');
|
||||
}
|
||||
}
|
||||
|
||||
BrowserDetection.setup();
|
||||
|
Reference in New Issue
Block a user