本文整理汇总了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;
}
}
}
开发者ID:russelgal,项目名称:inferno,代码行数:26,代码来源:TextareaWrapper.ts
示例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";
}
}
}
开发者ID:russelgal,项目名称:inferno,代码行数:37,代码来源:patching.ts
示例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;
}
}
}
开发者ID:russelgal,项目名称:inferno,代码行数:33,代码来源:InputWrapper.ts
示例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)
);
}
开发者ID:russelgal,项目名称:inferno,代码行数:10,代码来源:utils.ts
示例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);
}
};
开发者ID:russelgal,项目名称:inferno,代码行数:14,代码来源:index.ts
示例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));
}
}
}
开发者ID:russelgal,项目名称:inferno,代码行数:15,代码来源:mounting.ts
示例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;
}
}
开发者ID:russelgal,项目名称:inferno,代码行数:15,代码来源:SelectWrapper.ts
示例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;
}
开发者ID:russelgal,项目名称:inferno,代码行数:34,代码来源:index.ts
示例9: insertOrAppend
export function insertOrAppend(parentDom, newNode, nextNode) {
if (isNullOrUndef(nextNode)) {
appendChild(parentDom, newNode);
} else {
parentDom.insertBefore(newNode, nextNode);
}
}
开发者ID:russelgal,项目名称:inferno,代码行数:7,代码来源:utils.ts
示例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;
}
}
}
}
开发者ID:russelgal,项目名称:inferno,代码行数:32,代码来源:patching.ts
注:本文中的inferno-shared.isNullOrUndef函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论