How to use the riot.__.cssManager function in riot

To help you get started, we’ve selected a few riot examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github riot / hot-reload / test / index.js View on Github external
it('riot.reload will reload the css properly', () => {
    const api = {
      name: 'css-demo',
      css: ':host { color: rgb(255, 255, 255); }'
    }

    const div = document.createElement('div')
    document.body.appendChild(div)

    component(api)(div)

    expect(__.cssManager.CSS_BY_NAME.get('css-demo')).to.match(/rgb\(255, 255, 255\)/)

    hotReload({
      name: 'css-demo',
      css: ':host { color: rgb(0, 0, 0); }'
    })

    expect(__.cssManager.CSS_BY_NAME.get('css-demo')).to.match(/rgb\(0, 0, 0\)/)
  })
})
github riot / hot-reload / test / index.js View on Github external
css: ':host { color: rgb(255, 255, 255); }'
    }

    const div = document.createElement('div')
    document.body.appendChild(div)

    component(api)(div)

    expect(__.cssManager.CSS_BY_NAME.get('css-demo')).to.match(/rgb\(255, 255, 255\)/)

    hotReload({
      name: 'css-demo',
      css: ':host { color: rgb(0, 0, 0); }'
    })

    expect(__.cssManager.CSS_BY_NAME.get('css-demo')).to.match(/rgb\(0, 0, 0\)/)
  })
})
github riot / ssr / src / index.js View on Github external
import './register'
import {__, component} from 'riot'
import curry from 'curri'
import jsDOMGlobal from 'jsdom-global'

const {CSS_BY_NAME} = __.cssManager

const INPUT_ELEMENTS_SELECTOR = 'input,textarea,select,option'
const INPUT_PASSWORD_TYPE = 'password'
const VALUE_ATTRIBUTE = 'value'
const noop = () => {}

/**
 * Set the value attribute of all the inputs
 * @param {HTMLElement} element - root node
 * @return {HTMLElement[]} list of the matched input elements
 */
function setUserInputAttributes(element) {
  return element.$$(INPUT_ELEMENTS_SELECTOR).map(el => {
    const value = el.type !== INPUT_PASSWORD_TYPE ? el.value : ''
    el.setAttribute(VALUE_ATTRIBUTE, value || '')