diff --git a/src/lib/flexbox/api/base.ts b/src/lib/flexbox/api/base.ts index efc1abd14..b1665cd1f 100644 --- a/src/lib/flexbox/api/base.ts +++ b/src/lib/flexbox/api/base.ts @@ -17,6 +17,7 @@ import {buildLayoutCSS} from '../../utils/layout-validator'; import {ResponsiveActivation, KeyOptions} from '../responsive/responsive-activation'; import {MediaMonitor} from '../../media-query/media-monitor'; import {MediaQuerySubscriber} from '../../media-query/media-change'; +import {Node} from '@angular/compiler'; /** @@ -120,9 +121,16 @@ export abstract class BaseFxDirective implements OnDestroy, OnChanges { let element: HTMLElement = source || this._elementRef.nativeElement; let value = this._lookupStyle(element, 'display'); - return value ? value.trim() : ((element.nodeType === 1) ? 'block' : 'inline-block'); + return value ? value.trim() : + ((element.nodeType === 1) ? 'block' : 'inline-block'); } + /** + * Determine the DOM element's Flexbox flow (flex-direction). + * + * Check inline style first then check computed (stylesheet) style. + * And optionally add the flow value to element's inline style. + */ protected _getFlowDirection(target: any, addIfMissing = false): string { let value = 'row'; @@ -146,7 +154,7 @@ export abstract class BaseFxDirective implements OnDestroy, OnChanges { try { if (element) { let immediateValue = getDom().getStyle(element, styleName); - value = immediateValue || getDom().getComputedStyle(element).display; + value = immediateValue || getDom().getComputedStyle(element).getPropertyValue(styleName); } } catch (e) { // TODO: platform-server throws an exception for getComputedStyle diff --git a/src/lib/flexbox/api/flex.spec.ts b/src/lib/flexbox/api/flex.spec.ts index 8307e763c..99d68e3da 100644 --- a/src/lib/flexbox/api/flex.spec.ts +++ b/src/lib/flexbox/api/flex.spec.ts @@ -118,6 +118,26 @@ describe('flex directive', () => { expect(element).not.toHaveCssStyle({'min-width': '30px'}); }); + it('should CSS stylesheet and not inject flex-direction on parent', () => { + componentWithTemplate(` + +