polyfill-service
Version:
A polyfill combinator
1 lines • 3.77 kB
JSON
{"browsers":{"ie":"9 - *","ie_mob":"*","firefox":"*","chrome":"* - 37","safari":"*","ios_saf":"*","opera":"* - 24","op_mob":"*","android":"*","bb":"*","firefox_mob":"*"},"dependencies":["Object.defineProperty"],"notes":["In IE <= 8 window.screen is read-only, so the orientation property is not definable"],"spec":"http://www.w3.org/TR/screen-orientation/","docs":"https://developer.mozilla.org/en-US/docs/Web/API/Screen/orientation","baseDir":"screen/orientation","hasTests":true,"rawSource":"\n// screen.orientation\n(function() {\n\n\tvar propName, nativeGetter;\n\tvar err = ' not supported in the screen.orientation polyfill';\n\n\tfunction getVal() {\n\t\tvar val;\n\n\t\tif (nativeGetter) val = nativeGetter.call(window.screen);\n\n\t\t// If object we assume it's compliant with the spec\n\t\tif (typeof val === 'object') return val;\n\n\t\t// If no native implementation is available, guess based on screen width and height (impossible to tell whether device is upside down so consider both portrait orientations to be primary, likewise landscape)\n\t\tif (typeof val === 'undefined') {\n\t\t\tval = (screen.width > screen.height) ? 'landscape-primary' : 'portrait-primary';\n\t\t}\n\t\treturn {\n\t\t\ttype: val,\n\t\t\tangle: (val.indexOf('secondary') !== -1) ? 180 : 0,\n\t\t\tonchange: function() {\n\t\t\t\tthrow new Error('onchange'+err);\n\t\t\t},\n\t\t\tlock: function(){\n\t\t\t\tthrow new Error('lock method'+err);\n\t\t\t},\n\t\t\tunlock: function(){\n\t\t\t\tthrow new Error('unlock method'+err);\n\t\t\t}\n\t\t};\n\t}\n\n\t// Find a native impl if it exists\n\tif ('orientation' in screen) propName = 'orientation';\n\telse if ('mozOrientation' in screen) propName = 'mozOrientation';\n\telse if ('msOrientation' in screen) propName = 'msOrientation';\n\n\tnativeGetter = ('getOwnPropertyDescriptor' in Object && Object.getOwnPropertyDescriptor(window.screen, propName)) ||\n\t ('__lookupGetter__' in window.screen && window.screen.__lookupGetter__(propName));\n\n\t// For completeness, but no browser above our baseline lacks the screen property\n\tif (!('screen' in window)) window.screen = {};\n\n\t// If the value is not an object, the feature either doesn't exist or is incorrectly implemented\n\tif (typeof window.screen.orientation !== 'object') {\n\n\t\t// Attempt to use a dynamic getter, otherwise just set it to the initial value on load\n\t\ttry {\n\t\t\tObject.defineProperty(window.screen, 'orientation', {\n\t\t\t\tget: getVal\n\t\t\t});\n\t\t} catch(e1) {\n\n\t\t\t// screen is read-only in some browsers\n\t\t\ttry {\n\t\t\t\twindow.screen.orientation = getVal();\n\t\t\t} catch (e2) {}\n\t\t}\n\t}\n}());\n","minSource":"!function(){function n(){var n;return o&&(n=o.call(window.screen)),\"object\"==typeof n?n:(\"undefined\"==typeof n&&(n=screen.width>screen.height?\"landscape-primary\":\"portrait-primary\"),{type:n,angle:-1!==n.indexOf(\"secondary\")?180:0,onchange:function(){throw new Error(\"onchange\"+r)},lock:function(){throw new Error(\"lock method\"+r)},unlock:function(){throw new Error(\"unlock method\"+r)}})}var e,o,r=\" not supported in the screen.orientation polyfill\";if(\"orientation\"in screen?e=\"orientation\":\"mozOrientation\"in screen?e=\"mozOrientation\":\"msOrientation\"in screen&&(e=\"msOrientation\"),o=\"getOwnPropertyDescriptor\"in Object&&Object.getOwnPropertyDescriptor(window.screen,e)||\"__lookupGetter__\"in window.screen&&window.screen.__lookupGetter__(e),\"screen\"in window||(window.screen={}),\"object\"!=typeof window.screen.orientation)try{Object.defineProperty(window.screen,\"orientation\",{get:n})}catch(t){try{window.screen.orientation=n()}catch(i){}}}();","detectSource":"'screen' in this && 'orientation' in this.screen && typeof this.screen.orientation === 'object'"}