fix(platform-server): interpret Native view encapsulation as Emulated on the server (#15155)
PR Close #15155
This commit is contained in:
parent
a805d00256
commit
de3d2eeeba
|
@ -29,6 +29,7 @@ export class ServerRendererFactory2 implements RendererFactory2 {
|
||||||
return this.defaultRenderer;
|
return this.defaultRenderer;
|
||||||
}
|
}
|
||||||
switch (type.encapsulation) {
|
switch (type.encapsulation) {
|
||||||
|
case ViewEncapsulation.Native:
|
||||||
case ViewEncapsulation.Emulated: {
|
case ViewEncapsulation.Emulated: {
|
||||||
let renderer = this.rendererByCompId.get(type.id);
|
let renderer = this.rendererByCompId.get(type.id);
|
||||||
if (!renderer) {
|
if (!renderer) {
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
import {animate, style, transition, trigger} from '@angular/animations';
|
import {animate, style, transition, trigger} from '@angular/animations';
|
||||||
import {APP_BASE_HREF, PlatformLocation, isPlatformServer} from '@angular/common';
|
import {APP_BASE_HREF, PlatformLocation, isPlatformServer} from '@angular/common';
|
||||||
import {ApplicationRef, CompilerFactory, Component, HostListener, NgModule, NgModuleRef, NgZone, PLATFORM_ID, PlatformRef, destroyPlatform, getPlatform} from '@angular/core';
|
import {ApplicationRef, CompilerFactory, Component, HostListener, NgModule, NgModuleRef, NgZone, PLATFORM_ID, PlatformRef, ViewEncapsulation, destroyPlatform, getPlatform} from '@angular/core';
|
||||||
import {TestBed, async, inject} from '@angular/core/testing';
|
import {TestBed, async, inject} from '@angular/core/testing';
|
||||||
import {Http, HttpModule, Response, ResponseOptions, XHRBackend} from '@angular/http';
|
import {Http, HttpModule, Response, ResponseOptions, XHRBackend} from '@angular/http';
|
||||||
import {MockBackend, MockConnection} from '@angular/http/testing';
|
import {MockBackend, MockConnection} from '@angular/http/testing';
|
||||||
|
@ -149,6 +149,23 @@ class ImageApp {
|
||||||
class ImageExampleModule {
|
class ImageExampleModule {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app',
|
||||||
|
template: 'Native works',
|
||||||
|
encapsulation: ViewEncapsulation.Native,
|
||||||
|
styles: [':host { color: red; }']
|
||||||
|
})
|
||||||
|
class NativeEncapsulationApp {
|
||||||
|
}
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
declarations: [NativeEncapsulationApp],
|
||||||
|
imports: [BrowserModule.withServerTransition({appId: 'test'}), ServerModule],
|
||||||
|
bootstrap: [NativeEncapsulationApp]
|
||||||
|
})
|
||||||
|
class NativeExampleModule {
|
||||||
|
}
|
||||||
|
|
||||||
export function main() {
|
export function main() {
|
||||||
if (getDOM().supportsDOMEvents()) return; // NODE only
|
if (getDOM().supportsDOMEvents()) return; // NODE only
|
||||||
|
|
||||||
|
@ -381,6 +398,14 @@ export function main() {
|
||||||
called = true;
|
called = true;
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
it('should handle ViewEncapsulation.Native', async(() => {
|
||||||
|
renderModule(NativeExampleModule, {document: doc}).then(output => {
|
||||||
|
expect(output).not.toBe('');
|
||||||
|
expect(output).toContain('color: red');
|
||||||
|
called = true;
|
||||||
|
});
|
||||||
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('http', () => {
|
describe('http', () => {
|
||||||
|
|
Loading…
Reference in New Issue