MCPcopy Create free account
hub / github.com/Lucifier129/react-lite / isNode

Function isNode

examples/simple/react.js:12691–12736  ·  view source on GitHub ↗
(propValue)

Source from the content-addressed store, hash-verified

12689}
12690
12691function isNode(propValue) {
12692 switch (typeof propValue) {
12693 case 'number':
12694 case 'string':
12695 case 'undefined':
12696 return true;
12697 case 'boolean':
12698 return !propValue;
12699 case 'object':
12700 if (Array.isArray(propValue)) {
12701 return propValue.every(isNode);
12702 }
12703 if (propValue === null || ReactElement.isValidElement(propValue)) {
12704 return true;
12705 }
12706
12707 var iteratorFn = getIteratorFn(propValue);
12708 if (iteratorFn) {
12709 var iterator = iteratorFn.call(propValue);
12710 var step;
12711 if (iteratorFn !== propValue.entries) {
12712 while (!(step = iterator.next()).done) {
12713 if (!isNode(step.value)) {
12714 return false;
12715 }
12716 }
12717 } else {
12718 // Iterator will provide entry [k,v] tuples rather than values.
12719 while (!(step = iterator.next()).done) {
12720 var entry = step.value;
12721 if (entry) {
12722 if (!isNode(entry[1])) {
12723 return false;
12724 }
12725 }
12726 }
12727 }
12728 } else {
12729 return false;
12730 }
12731
12732 return true;
12733 default:
12734 return false;
12735 }
12736}
12737
12738// Equivalent of `typeof` but with special handling for array and regexp.
12739function getPropType(propValue) {

Callers 2

validateFunction · 0.85
isTextNodeFunction · 0.85

Calls 1

getIteratorFnFunction · 0.70

Tested by

no test coverage detected