fix(platform-server): interpret Native view encapsulation as Emulated on the server (#15155)

PR Close #15155
This commit is contained in:
Alex Rickabaugh 2017-03-14 14:09:24 -07:00 committed by Miško Hevery
parent a805d00256
commit de3d2eeeba
2 changed files with 27 additions and 1 deletions

View File

@ -29,6 +29,7 @@ export class ServerRendererFactory2 implements RendererFactory2 {
return this.defaultRenderer;
}
switch (type.encapsulation) {
case ViewEncapsulation.Native:
case ViewEncapsulation.Emulated: {
let renderer = this.rendererByCompId.get(type.id);
if (!renderer) {

View File

@ -8,7 +8,7 @@
import {animate, style, transition, trigger} from '@angular/animations';
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 {Http, HttpModule, Response, ResponseOptions, XHRBackend} from '@angular/http';
import {MockBackend, MockConnection} from '@angular/http/testing';
@ -149,6 +149,23 @@ class ImageApp {
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() {
if (getDOM().supportsDOMEvents()) return; // NODE only
@ -381,6 +398,14 @@ export function main() {
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', () => {