Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// TODO when refactoring properties to not have to workaround the old
// WebKit bug we can remove the "name in props" check below.
//
// NOTE: That the "name in elem" check won't work for polyfilled custom
// elements that set a property that isn't explicitly specified in "props"
// or "prototype" unless it is added to the element explicitly as a
// property prior to passing the prop to the vdom function. For example, if
// it were added in a lifecycle callback because it wouldn't have been
// upgraded yet.
//
// We prefer setting props, so we do this if there's a property matching
// name that was passed. However, certain props on SVG elements are
// readonly and error when you try to set them.
if ((name in props || name in elem || name in prototype) && !('ownerSVGElement' in elem)) {
applyProp(elem, name, value);
return;
}
// Explicit false removes the attribute.
if (value === false) {
applyDefault(elem, name);
return;
}
// Handle built-in and custom events.
if (name.indexOf('on') === 0) {
const firstChar = name[2];
let eventName;
if (firstChar === '-') {
eventName = name.substring(3);
attributes.is = (target, name, value) => {
if (target.setAttribute) applyAttr(target, name, value)
return applyProp(target, name, value)
}
attributes[symbols.default] = applyProp
function applyAttribute(el, name, value) {
let type = typeof value
let prop = PROPERTIES[name]
if(prop) {
applyProp(el, prop, value)
} else if (type === 'object' || type === 'function' || type == 'boolean') {
applyProp(el, name, value)
} else {
applyAttr(el, name, value)
}
}
function applyAttribute(el, name, value) {
let type = typeof value
let prop = PROPERTIES[name]
if(prop) {
applyProp(el, prop, value)
} else if (type === 'object' || type === 'function' || type == 'boolean') {
applyProp(el, name, value)
} else {
applyAttr(el, name, value)
}
}
attributes.is = (target, name, value) => {
if (target.setAttribute) applyAttr(target, name, value)
return applyProp(target, name, value)
}
attributes[symbols.default] = applyProp