3b881790bf3ffb618e8469f071e2b92bd6616d09
[yaffs-website] / node_modules / video.js / es5 / utils / computed-style.js
1 'use strict';
2
3 exports.__esModule = true;
4 exports['default'] = computedStyle;
5
6 var _window = require('global/window');
7
8 var _window2 = _interopRequireDefault(_window);
9
10 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
11
12 /**
13  * A safe getComputedStyle with an IE8 fallback.
14  *
15  * This is needed because in Firefox, if the player is loaded in an iframe with
16  * `display:none`, then `getComputedStyle` returns `null`, so, we do a null-check to
17  * make sure  that the player doesn't break in these cases.
18  *
19  * @param {Element} el
20  *        The element you want the computed style of
21  *
22  * @param {string} prop
23  *        The property name you want
24  *
25  * @see https://bugzilla.mozilla.org/show_bug.cgi?id=548397
26  */
27 function computedStyle(el, prop) {
28   if (!el || !prop) {
29     return '';
30   }
31
32   if (typeof _window2['default'].getComputedStyle === 'function') {
33     var cs = _window2['default'].getComputedStyle(el);
34
35     return cs ? cs[prop] : '';
36   }
37
38   return el.currentStyle[prop] || '';
39 } /**
40    * @file computed-style.js
41    * @module computed-style
42    */