Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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\)/)
})
})
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\)/)
})
})
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 || '')