本文整理汇总了TypeScript中inferno-shared.isNullOrUndef函数的典型用法代码示例。如果您正苦于以下问题:TypeScript isNullOrUndef函数的具体用法?TypeScript isNullOrUndef怎么用?TypeScript isNullOrUndef使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了isNullOrUndef函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: applyValue
export function applyValue(nextPropsOrEmpty, dom, mounting: boolean) {
const value = nextPropsOrEmpty.value;
const domValue = dom.value;
if (isNullOrUndef(value)) {
if (mounting) {
const defaultValue = nextPropsOrEmpty.defaultValue;
if (!isNullOrUndef(defaultValue)) {
if (defaultValue !== domValue) {
dom.defaultValue = defaultValue;
dom.value = defaultValue;
}
} else if (domValue !== "") {
dom.defaultValue = "";
dom.value = "";
}
}
} else {
/* There is value so keep it controlled */
if (domValue !== value) {
dom.defaultValue = value;
dom.value = value;
}
}
}
示例2: patchStyle
// We are assuming here that we come from patchProp routine
// -nextAttrValue cannot be null or undefined
function patchStyle(lastAttrValue, nextAttrValue, dom) {
const domStyle = dom.style;
let style;
let value;
if (isString(nextAttrValue)) {
domStyle.cssText = nextAttrValue;
return;
}
if (!isNullOrUndef(lastAttrValue) && !isString(lastAttrValue)) {
for (style in nextAttrValue) {
// do not add a hasOwnProperty check here, it affects performance
value = nextAttrValue[style];
if (value !== lastAttrValue[style]) {
domStyle[style] =
!isNumber(value) || isUnitlessNumber.has(style)
? value
: value + "px";
}
}
for (style in lastAttrValue) {
if (isNullOrUndef(nextAttrValue[style])) {
domStyle[style] = "";
}
}
} else {
for (style in nextAttrValue) {
value = nextAttrValue[style];
domStyle[style] =
!isNumber(value) || isUnitlessNumber.has(style) ? value : value + "px";
}
}
}
示例3: applyValue
export function applyValue(nextPropsOrEmpty, dom) {
const type = nextPropsOrEmpty.type;
const value = nextPropsOrEmpty.value;
const checked = nextPropsOrEmpty.checked;
const multiple = nextPropsOrEmpty.multiple;
const defaultValue = nextPropsOrEmpty.defaultValue;
const hasValue = !isNullOrUndef(value);
if (type && type !== dom.type) {
dom.setAttribute("type", type);
}
if (multiple && multiple !== dom.multiple) {
dom.multiple = multiple;
}
if (!isNullOrUndef(defaultValue) && !hasValue) {
dom.defaultValue = defaultValue + "";
}
if (isCheckedType(type)) {
if (hasValue) {
dom.value = value;
}
if (!isNullOrUndef(checked)) {
dom.checked = checked;
}
} else {
if (hasValue && dom.value !== value) {
dom.defaultValue = value;
dom.value = value;
} else if (!isNullOrUndef(checked)) {
dom.checked = checked;
}
}
}
示例4: isKeyed
export function isKeyed(lastChildren: VNode[], nextChildren: VNode[]): boolean {
return (
nextChildren.length > 0 &&
!isNullOrUndef(nextChildren[0]) &&
!isNullOrUndef(nextChildren[0].key) &&
lastChildren.length > 0 &&
!isNullOrUndef(lastChildren[0]) &&
!isNullOrUndef(lastChildren[0].key)
);
}
示例5: oldCreateVNode
options.createVNode = (vNode: VNode): void => {
const children = vNode.children;
let props = vNode.props;
if (isNullOrUndef(props)) {
props = vNode.props = {};
}
if (!isNullOrUndef(children) && isNullOrUndef(props.children)) {
props.children = children;
}
if (oldCreateVNode) {
oldCreateVNode(vNode);
}
};
示例6: mountFunctionalComponentCallbacks
export function mountFunctionalComponentCallbacks(
props,
ref,
dom,
lifecycle: LifecycleClass
) {
if (ref) {
if (!isNullOrUndef(ref.onComponentWillMount)) {
ref.onComponentWillMount(props);
}
if (!isNullOrUndef(ref.onComponentDidMount)) {
lifecycle.addListener(() => ref.onComponentDidMount(dom, props));
}
}
}
示例7: updateChildOption
function updateChildOption(vNode, value) {
const props = vNode.props || EMPTY_OBJ;
const dom = vNode.dom;
// we do this as multiple may have changed
dom.value = props.value;
if (
(isArray(value) && value.indexOf(props.value) !== -1) ||
props.value === value
) {
dom.selected = true;
} else if (!isNullOrUndef(value) || !isNullOrUndef(props.selected)) {
dom.selected = props.selected || false;
}
}
示例8: validateNodeTree
export function validateNodeTree(node: any): boolean {
if (!node) {
return true;
}
if (isStringOrNumber(node)) {
return true;
}
if (!node.dom) {
return false;
}
const children = node.children;
const flags = node.flags;
if ((flags & VNodeFlags.Element) > 0) {
if (!isNullOrUndef(children)) {
if (isArray(children)) {
for (const child of children) {
const val = validateNodeTree(child);
if (!val) {
return false;
}
}
} else {
const val = validateNodeTree(children);
if (!val) {
return false;
}
}
}
}
return true;
}
示例9: insertOrAppend
export function insertOrAppend(parentDom, newNode, nextNode) {
if (isNullOrUndef(nextNode)) {
appendChild(parentDom, newNode);
} else {
parentDom.insertBefore(newNode, nextNode);
}
}
示例10: patchEvent
export function patchEvent(name: string, lastValue, nextValue, dom) {
if (lastValue !== nextValue) {
if (delegatedEvents.has(name)) {
handleEvent(name, lastValue, nextValue, dom);
} else {
const nameLowerCase = name.toLowerCase();
const domEvent = dom[nameLowerCase];
// if the function is wrapped, that means it's been controlled by a wrapper
if (domEvent && domEvent.wrapped) {
return;
}
if (!isFunction(nextValue) && !isNullOrUndef(nextValue)) {
const linkEvent = nextValue.event;
if (linkEvent && isFunction(linkEvent)) {
dom[nameLowerCase] = function(e) {
linkEvent(nextValue.data, e);
};
} else {
if (process.env.NODE_ENV !== "production") {
throwError(
`an event on a VNode "${name}". was not a function or a valid linkEvent.`
);
}
throwError();
}
} else {
dom[nameLowerCase] = nextValue;
}
}
}
}