All files util.js

100% Statements 30/30
100% Branches 9/9
100% Functions 2/2
100% Lines 30/30

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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 312x 2x 2x 2x 2x 2x 9x 9x 9x 1x 1x 9x 2x 2x 2x 2x 2x 2x 10x 11x 19x 19x 3x 2x 3x 1x 1x 3x 11x 9x  
/**
 * Calls customElements.define without breaking flow if an error happens
 * @param {string} name - Name for the new custom element. Must be a valid custom element name.
 * @param {CustomElementConstructor} constructor - Name for the new custom element. Must be a valid custom element name.
 */
export function registerElement (name, constructor) {
  try {
    customElements.define(name, constructor)
  } catch (error) {
    console.error(error)
  }
}
 
/**
 * Registers CSS properties to fix Chorme "allow-discrete" transition on Chrome
 * @see https://issues.chromium.org/issues/360159391
 */
export function registerCSSProperties () {
  for (const [name, inherits] of /** @type {const} */([['--default-ui-mode', false], ['--ui-mode', true]])) {
    try {
      CSS.registerProperty({ name, inherits })
    } catch (e) {
      if (e instanceof DOMException) {
        // property registered, ignore it
      } else {
        throw e // re-throw the error
      }
    }
  }
}