| OLD | NEW |
| (Empty) | |
| 1 /** |
| 2 @license |
| 3 Copyright (c) 2017 The Polymer Project Authors. All rights reserved. |
| 4 This code may only be used under the BSD style license found at http://polymer.g
ithub.io/LICENSE.txt |
| 5 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt |
| 6 The complete set of contributors may be found at http://polymer.github.io/CONTRI
BUTORS.txt |
| 7 Code distributed by Google as part of the polymer project is also |
| 8 subject to an additional IP rights grant found at http://polymer.github.io/PATEN
TS.txt |
| 9 */ |
| 10 |
| 11 'use strict'; |
| 12 |
| 13 import { MIXIN_MATCH, VAR_ASSIGN } from './common-regex' |
| 14 |
| 15 /** |
| 16 * @param {Element} element |
| 17 * @param {Object=} properties |
| 18 */ |
| 19 export function updateNativeProperties(element, properties) { |
| 20 // remove previous properties |
| 21 for (let p in properties) { |
| 22 // NOTE: for bc with shim, don't apply null values. |
| 23 if (p === null) { |
| 24 element.style.removeProperty(p); |
| 25 } else { |
| 26 element.style.setProperty(p, properties[p]); |
| 27 } |
| 28 } |
| 29 } |
| 30 |
| 31 /** |
| 32 * @param {Element} element |
| 33 * @param {string} property |
| 34 * @return {string} |
| 35 */ |
| 36 export function getComputedStyleValue(element, property) { |
| 37 /** |
| 38 * @const {string} |
| 39 */ |
| 40 const value = window.getComputedStyle(element).getPropertyValue(property); |
| 41 if (!value) { |
| 42 return ''; |
| 43 } else { |
| 44 return value.trim(); |
| 45 } |
| 46 } |
| 47 |
| 48 /** |
| 49 * return true if `cssText` contains a mixin definition or consumption |
| 50 * @param {string} cssText |
| 51 * @return {boolean} |
| 52 */ |
| 53 export function detectMixin(cssText) { |
| 54 const has = MIXIN_MATCH.test(cssText) || VAR_ASSIGN.test(cssText); |
| 55 // reset state of the regexes |
| 56 MIXIN_MATCH.lastIndex = 0; |
| 57 VAR_ASSIGN.lastIndex = 0; |
| 58 return has; |
| 59 } |
| OLD | NEW |