all files / lib/src/utils/ browser.js

100% Statements 34/34
61.29% Branches 19/31
100% Functions 8/8
100% Lines 31/31
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70                         14×   14×       20×                                              
export var getPrefixedStyleProperty = (function () {
	var properties = {}
	var style = document.documentElement.style
 
	function getPrefixedStyleProperty (name, source) {
		if ( source === void 0 ) source = style;
 
		if (name && typeof name === 'string') {
			if (properties[name]) {
				return properties[name]
			}
			if (typeof source[name] === 'string') {
				return properties[name] = name
			}
			if (typeof source[("-webkit-" + name)] === 'string') {
				return properties[name] = "-webkit-" + name
			}
			throw new RangeError(("Unable to find \"" + name + "\" style property."))
		}
		throw new TypeError('Expected a string.')
	}
 
	getPrefixedStyleProperty.clearCache = function () { return properties = {}; }
 
	return getPrefixedStyleProperty
})()
 
 
export function isMobile (agent) {
	if ( agent === void 0 ) agent = navigator.userAgent;
 
	return /Android|iPhone|iPad|iPod/i.test(agent)
}
 
 
export function isNode (target) {
	return typeof window.Node === 'object'
		? target instanceof window.Node
		: target !== null
			&& typeof target === 'object'
			&& typeof target.nodeType === 'number'
			&& typeof target.nodeName === 'string'
}
 
 
export function isNodeList (target) {
	var prototypeToString = Object.prototype.toString.call(target)
	var regex = /^\[object (HTMLCollection|NodeList|Object)\]$/
 
	return typeof window.NodeList === 'object'
		? target instanceof window.NodeList
		: typeof target === 'object'
			&& typeof target.length === 'number'
			&& regex.test(prototypeToString)
			&& (target.length === 0 || isNode(target[0]))
}
 
 
export function transformSupported () {
	var style = document.documentElement.style
	return 'transform' in style || 'WebkitTransform' in style
}
 
 
export function transitionSupported () {
	var style = document.documentElement.style
	return 'transition' in style || 'WebkitTransition' in style
}