fix(animations): set animations styles properly on platform-server (#24624)

Animations styles weren't getting properly set on platform-server because of erroneous checks and absence of reflection of style property to attribute on the server.

The fix corrects the check for platform and explicitly reflects the style property to the attribute.

PR Close #24624
This commit is contained in:
Vikram Subramanian
2018-06-21 22:55:47 -07:00
committed by Miško Hevery
parent 1e139d4339
commit 6e20e0aac8
4 changed files with 71 additions and 5 deletions

View File

@ -14,6 +14,10 @@ export function isBrowser() {
return (typeof window !== 'undefined' && typeof window.document !== 'undefined');
}
export function isNode() {
return (typeof process !== 'undefined');
}
export function optimizeGroupPlayer(players: AnimationPlayer[]): AnimationPlayer {
switch (players.length) {
case 0:
@ -142,11 +146,14 @@ let _query: (element: any, selector: string, multi: boolean) => any[] =
return [];
};
if (isBrowser()) {
// Define utility methods for browsers and platform-server(domino) where Element
// and utility methods exist.
const _isNode = isNode();
if (_isNode || typeof Element !== 'undefined') {
// this is well supported in all browsers
_contains = (elm1: any, elm2: any) => { return elm1.contains(elm2) as boolean; };
if (Element.prototype.matches) {
if (_isNode || Element.prototype.matches) {
_matches = (element: any, selector: string) => element.matches(selector);
} else {
const proto = Element.prototype as any;