Sha256: c02539566495e6b59de399bb5cd3e4d18af85d02c25ae77e72bd6b684b04e47f
Contents?: true
Size: 1.34 KB
Versions: 5
Compression:
Stored size: 1.34 KB
Contents
<!-- @license Copyright (c) 2016 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE The complete set of authors may be found at http://polymer.github.io/AUTHORS The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS --> <script> /** * Checks if an element has a given CSS text * * @param {HTMLElement} el * @param {string} cssText */ function sameCSS(el, cssText) { var propName; var dummy = document.createElement('div'); dummy.style.cssText = cssText; document.body.appendChild(dummy); var elStyle = window.getComputedStyle(el); var parts = cssText.split(/\s/); var dummyStyle = window.getComputedStyle(dummy); for (var i = 0; i < parts.length; i++) { if (parts[i].substr(-1, 1) != ':') { continue; } propName = parts[i].substr(0, parts[i].length - 1); if (elStyle[propName] && elStyle[propName] !== dummyStyle[propName]) { throw new Error('`' + propName + '` is different: ' + '`' + elStyle[propName] + '` != `' + dummyStyle[propName] + '`'); } } return true; } </script>
Version data entries
5 entries across 5 versions & 1 rubygems