How to use placeSingleChild method in Playwright Internal

Best JavaScript code snippet using playwright-internal

4cb8b9d0ed5f067ca4dd9e921b4190df7c25aaReactChildFiber.js

Source:4cb8b9d0ed5f067ca4dd9e921b4190df7c25aaReactChildFiber.js Github

copy

Full Screen

...165 newFiber.effectTag = Placement;166 return lastPlacedIndex;167 }168 }169 function placeSingleChild(newFiber) {170 if (shouldTrackSideEffects && newFiber.alternate === null) {171 newFiber.effectTag = Placement;172 }173 return newFiber;174 }175 function updateTextNode(returnFiber, current, textContent, priority) {176 if (current === null || current.tag !== HostText) {177 var created = createFiberFromText(textContent, priority);178 created.return = returnFiber;179 return created;180 } else {181 var existing = useFiber(current, priority);182 existing.pendingProps = textContent;183 existing.return = returnFiber;184 return existing;185 }186 }187 function updateElement(returnFiber, current, element, priority) {188 if (current === null || current.type !== element.type) {189 var created = createFiberFromElement(element, priority);190 created.ref = coerceRef(current, element);191 created.return = returnFiber;192 return created;193 } else {194 var existing = useFiber(current, priority);195 existing.ref = coerceRef(current, element);196 existing.pendingProps = element.props;197 existing.return = returnFiber;198 if (__DEV__) {199 existing._debugSource = element._source;200 existing._debugOwner = element._owner;201 }202 return existing;203 }204 }205 function updateCoroutine(returnFiber, current, coroutine, priority) {206 if (current === null || current.tag !== CoroutineComponent) {207 var created = createFiberFromCoroutine(coroutine, priority);208 created.return = returnFiber;209 return created;210 } else {211 var existing = useFiber(current, priority);212 existing.pendingProps = coroutine;213 existing.return = returnFiber;214 return existing;215 }216 }217 function updateYield(returnFiber, current, yieldNode, priority) {218 if (current === null || current.tag !== YieldComponent) {219 var created = createFiberFromYield(yieldNode, priority);220 created.type = yieldNode.value;221 created.return = returnFiber;222 return created;223 } else {224 var existing = useFiber(current, priority);225 existing.type = yieldNode.value;226 existing.return = returnFiber;227 return existing;228 }229 }230 function updatePortal(returnFiber, current, portal, priority) {231 if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {232 var created = createFiberFromPortal(portal, priority);233 created.return = returnFiber;234 return created;235 } else {236 var existing = useFiber(current, priority);237 existing.pendingProps = portal.children || [];238 existing.return = returnFiber;239 return existing;240 }241 }242 function updateFragment(returnFiber, current, fragment, priority) {243 if (current === null || current.tag !== Fragment) {244 var created = createFiberFromFragment(fragment, priority);245 created.return = returnFiber;246 return created;247 } else {248 var existing = useFiber(current, priority);249 existing.pendingProps = fragment;250 existing.return = returnFiber;251 return existing;252 }253 }254 function createChild(returnFiber, newChild, priority) {255 if (typeof newChild === 'string' || typeof newChild === 'number') {256 var created = createFiberFromText('' + newChild, priority);257 created.return = returnFiber;258 return created;259 }260 if (typeof newChild === 'object' && newChild !== null) {261 switch (newChild.$$typeof) {262 case REACT_ELEMENT_TYPE:263 {264 var _created = createFiberFromElement(newChild, priority);265 _created.ref = coerceRef(null, newChild);266 _created.return = returnFiber;267 return _created;268 }269 case REACT_COROUTINE_TYPE:270 {271 var _created2 = createFiberFromCoroutine(newChild, priority);272 _created2.return = returnFiber;273 return _created2;274 }275 case REACT_YIELD_TYPE:276 {277 var _created3 = createFiberFromYield(newChild, priority);278 _created3.type = newChild.value;279 _created3.return = returnFiber;280 return _created3;281 }282 case REACT_PORTAL_TYPE:283 {284 var _created4 = createFiberFromPortal(newChild, priority);285 _created4.return = returnFiber;286 return _created4;287 }288 }289 if (isArray(newChild) || getIteratorFn(newChild)) {290 var _created5 = createFiberFromFragment(newChild, priority);291 _created5.return = returnFiber;292 return _created5;293 }294 throwOnInvalidObjectType(returnFiber, newChild);295 }296 return null;297 }298 function updateSlot(returnFiber, oldFiber, newChild, priority) {299 var key = oldFiber !== null ? oldFiber.key : null;300 if (typeof newChild === 'string' || typeof newChild === 'number') {301 if (key !== null) {302 return null;303 }304 return updateTextNode(returnFiber, oldFiber, '' + newChild, priority);305 }306 if (typeof newChild === 'object' && newChild !== null) {307 switch (newChild.$$typeof) {308 case REACT_ELEMENT_TYPE:309 {310 if (newChild.key === key) {311 return updateElement(returnFiber, oldFiber, newChild, priority);312 } else {313 return null;314 }315 }316 case REACT_COROUTINE_TYPE:317 {318 if (newChild.key === key) {319 return updateCoroutine(returnFiber, oldFiber, newChild, priority);320 } else {321 return null;322 }323 }324 case REACT_YIELD_TYPE:325 {326 if (key === null) {327 return updateYield(returnFiber, oldFiber, newChild, priority);328 } else {329 return null;330 }331 }332 case REACT_PORTAL_TYPE:333 {334 if (newChild.key === key) {335 return updatePortal(returnFiber, oldFiber, newChild, priority);336 } else {337 return null;338 }339 }340 }341 if (isArray(newChild) || getIteratorFn(newChild)) {342 if (key !== null) {343 return null;344 }345 return updateFragment(returnFiber, oldFiber, newChild, priority);346 }347 throwOnInvalidObjectType(returnFiber, newChild);348 }349 return null;350 }351 function updateFromMap(existingChildren, returnFiber, newIdx, newChild, priority) {352 if (typeof newChild === 'string' || typeof newChild === 'number') {353 var matchedFiber = existingChildren.get(newIdx) || null;354 return updateTextNode(returnFiber, matchedFiber, '' + newChild, priority);355 }356 if (typeof newChild === 'object' && newChild !== null) {357 switch (newChild.$$typeof) {358 case REACT_ELEMENT_TYPE:359 {360 var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;361 return updateElement(returnFiber, _matchedFiber, newChild, priority);362 }363 case REACT_COROUTINE_TYPE:364 {365 var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;366 return updateCoroutine(returnFiber, _matchedFiber2, newChild, priority);367 }368 case REACT_YIELD_TYPE:369 {370 var _matchedFiber3 = existingChildren.get(newIdx) || null;371 return updateYield(returnFiber, _matchedFiber3, newChild, priority);372 }373 case REACT_PORTAL_TYPE:374 {375 var _matchedFiber4 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;376 return updatePortal(returnFiber, _matchedFiber4, newChild, priority);377 }378 }379 if (isArray(newChild) || getIteratorFn(newChild)) {380 var _matchedFiber5 = existingChildren.get(newIdx) || null;381 return updateFragment(returnFiber, _matchedFiber5, newChild, priority);382 }383 throwOnInvalidObjectType(returnFiber, newChild);384 }385 return null;386 }387 function warnOnDuplicateKey(child, knownKeys) {388 if (__DEV__) {389 if (typeof child !== 'object' || child === null) {390 return knownKeys;391 }392 switch (child.$$typeof) {393 case REACT_ELEMENT_TYPE:394 case REACT_COROUTINE_TYPE:395 case REACT_PORTAL_TYPE:396 var key = child.key;397 if (typeof key !== 'string') {398 break;399 }400 if (knownKeys === null) {401 knownKeys = new Set();402 knownKeys.add(key);403 break;404 }405 if (!knownKeys.has(key)) {406 knownKeys.add(key);407 break;408 }409 warning(false, 'Encountered two children with the same key, ' + '`%s`. Child keys must be unique; when two children share a key, ' + 'only the first child will be used.%s', key, getCurrentFiberStackAddendum());410 break;411 default:412 break;413 }414 }415 return knownKeys;416 }417 function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, priority) {418 if (__DEV__) {419 var knownKeys = null;420 for (var i = 0; i < newChildren.length; i++) {421 var child = newChildren[i];422 knownKeys = warnOnDuplicateKey(child, knownKeys);423 }424 }425 var resultingFirstChild = null;426 var previousNewFiber = null;427 var oldFiber = currentFirstChild;428 var lastPlacedIndex = 0;429 var newIdx = 0;430 var nextOldFiber = null;431 for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {432 if (oldFiber.index > newIdx) {433 nextOldFiber = oldFiber;434 oldFiber = null;435 } else {436 nextOldFiber = oldFiber.sibling;437 }438 var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], priority);439 if (newFiber === null) {440 if (oldFiber === null) {441 oldFiber = nextOldFiber;442 }443 break;444 }445 if (shouldTrackSideEffects) {446 if (oldFiber && newFiber.alternate === null) {447 deleteChild(returnFiber, oldFiber);448 }449 }450 lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);451 if (previousNewFiber === null) {452 resultingFirstChild = newFiber;453 } else {454 previousNewFiber.sibling = newFiber;455 }456 previousNewFiber = newFiber;457 oldFiber = nextOldFiber;458 }459 if (newIdx === newChildren.length) {460 deleteRemainingChildren(returnFiber, oldFiber);461 return resultingFirstChild;462 }463 if (oldFiber === null) {464 for (; newIdx < newChildren.length; newIdx++) {465 var _newFiber = createChild(returnFiber, newChildren[newIdx], priority);466 if (!_newFiber) {467 continue;468 }469 lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);470 if (previousNewFiber === null) {471 resultingFirstChild = _newFiber;472 } else {473 previousNewFiber.sibling = _newFiber;474 }475 previousNewFiber = _newFiber;476 }477 return resultingFirstChild;478 }479 var existingChildren = mapRemainingChildren(returnFiber, oldFiber);480 for (; newIdx < newChildren.length; newIdx++) {481 var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], priority);482 if (_newFiber2) {483 if (shouldTrackSideEffects) {484 if (_newFiber2.alternate !== null) {485 existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);486 }487 }488 lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);489 if (previousNewFiber === null) {490 resultingFirstChild = _newFiber2;491 } else {492 previousNewFiber.sibling = _newFiber2;493 }494 previousNewFiber = _newFiber2;495 }496 }497 if (shouldTrackSideEffects) {498 existingChildren.forEach(function (child) {499 return deleteChild(returnFiber, child);500 });501 }502 return resultingFirstChild;503 }504 function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, priority) {505 var iteratorFn = getIteratorFn(newChildrenIterable);506 invariant(typeof iteratorFn === 'function', 'An object is not an iterable. This error is likely caused by a bug in ' + 'React. Please file an issue.');507 if (__DEV__) {508 if (typeof newChildrenIterable.entries === 'function') {509 var possibleMap = newChildrenIterable;510 if (possibleMap.entries === iteratorFn) {511 var mapsAsChildrenAddendum = '';512 var owner = ReactCurrentOwner.owner || returnFiber._debugOwner;513 if (owner && typeof owner.tag === 'number') {514 var mapsAsChildrenOwnerName = getComponentName(owner);515 if (mapsAsChildrenOwnerName) {516 mapsAsChildrenAddendum = '\n\nCheck the render method of `' + mapsAsChildrenOwnerName + '`.';517 }518 }519 warning(didWarnAboutMaps, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.%s', mapsAsChildrenAddendum);520 didWarnAboutMaps = true;521 }522 }523 var _newChildren = iteratorFn.call(newChildrenIterable);524 if (_newChildren) {525 var knownKeys = null;526 var _step = _newChildren.next();527 for (; !_step.done; _step = _newChildren.next()) {528 var child = _step.value;529 knownKeys = warnOnDuplicateKey(child, knownKeys);530 }531 }532 }533 var newChildren = iteratorFn.call(newChildrenIterable);534 invariant(newChildren != null, 'An iterable object provided no iterator.');535 var resultingFirstChild = null;536 var previousNewFiber = null;537 var oldFiber = currentFirstChild;538 var lastPlacedIndex = 0;539 var newIdx = 0;540 var nextOldFiber = null;541 var step = newChildren.next();542 for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {543 if (oldFiber.index > newIdx) {544 nextOldFiber = oldFiber;545 oldFiber = null;546 } else {547 nextOldFiber = oldFiber.sibling;548 }549 var newFiber = updateSlot(returnFiber, oldFiber, step.value, priority);550 if (newFiber === null) {551 if (!oldFiber) {552 oldFiber = nextOldFiber;553 }554 break;555 }556 if (shouldTrackSideEffects) {557 if (oldFiber && newFiber.alternate === null) {558 deleteChild(returnFiber, oldFiber);559 }560 }561 lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);562 if (previousNewFiber === null) {563 resultingFirstChild = newFiber;564 } else {565 previousNewFiber.sibling = newFiber;566 }567 previousNewFiber = newFiber;568 oldFiber = nextOldFiber;569 }570 if (step.done) {571 deleteRemainingChildren(returnFiber, oldFiber);572 return resultingFirstChild;573 }574 if (oldFiber === null) {575 for (; !step.done; newIdx++, step = newChildren.next()) {576 var _newFiber3 = createChild(returnFiber, step.value, priority);577 if (_newFiber3 === null) {578 continue;579 }580 lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);581 if (previousNewFiber === null) {582 resultingFirstChild = _newFiber3;583 } else {584 previousNewFiber.sibling = _newFiber3;585 }586 previousNewFiber = _newFiber3;587 }588 return resultingFirstChild;589 }590 var existingChildren = mapRemainingChildren(returnFiber, oldFiber);591 for (; !step.done; newIdx++, step = newChildren.next()) {592 var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, priority);593 if (_newFiber4 !== null) {594 if (shouldTrackSideEffects) {595 if (_newFiber4.alternate !== null) {596 existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);597 }598 }599 lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);600 if (previousNewFiber === null) {601 resultingFirstChild = _newFiber4;602 } else {603 previousNewFiber.sibling = _newFiber4;604 }605 previousNewFiber = _newFiber4;606 }607 }608 if (shouldTrackSideEffects) {609 existingChildren.forEach(function (child) {610 return deleteChild(returnFiber, child);611 });612 }613 return resultingFirstChild;614 }615 function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, priority) {616 if (currentFirstChild !== null && currentFirstChild.tag === HostText) {617 deleteRemainingChildren(returnFiber, currentFirstChild.sibling);618 var existing = useFiber(currentFirstChild, priority);619 existing.pendingProps = textContent;620 existing.return = returnFiber;621 return existing;622 }623 deleteRemainingChildren(returnFiber, currentFirstChild);624 var created = createFiberFromText(textContent, priority);625 created.return = returnFiber;626 return created;627 }628 function reconcileSingleElement(returnFiber, currentFirstChild, element, priority) {629 var key = element.key;630 var child = currentFirstChild;631 while (child !== null) {632 if (child.key === key) {633 if (child.type === element.type) {634 deleteRemainingChildren(returnFiber, child.sibling);635 var existing = useFiber(child, priority);636 existing.ref = coerceRef(child, element);637 existing.pendingProps = element.props;638 existing.return = returnFiber;639 if (__DEV__) {640 existing._debugSource = element._source;641 existing._debugOwner = element._owner;642 }643 return existing;644 } else {645 deleteRemainingChildren(returnFiber, child);646 break;647 }648 } else {649 deleteChild(returnFiber, child);650 }651 child = child.sibling;652 }653 var created = createFiberFromElement(element, priority);654 created.ref = coerceRef(currentFirstChild, element);655 created.return = returnFiber;656 return created;657 }658 function reconcileSingleCoroutine(returnFiber, currentFirstChild, coroutine, priority) {659 var key = coroutine.key;660 var child = currentFirstChild;661 while (child !== null) {662 if (child.key === key) {663 if (child.tag === CoroutineComponent) {664 deleteRemainingChildren(returnFiber, child.sibling);665 var existing = useFiber(child, priority);666 existing.pendingProps = coroutine;667 existing.return = returnFiber;668 return existing;669 } else {670 deleteRemainingChildren(returnFiber, child);671 break;672 }673 } else {674 deleteChild(returnFiber, child);675 }676 child = child.sibling;677 }678 var created = createFiberFromCoroutine(coroutine, priority);679 created.return = returnFiber;680 return created;681 }682 function reconcileSingleYield(returnFiber, currentFirstChild, yieldNode, priority) {683 var child = currentFirstChild;684 if (child !== null) {685 if (child.tag === YieldComponent) {686 deleteRemainingChildren(returnFiber, child.sibling);687 var existing = useFiber(child, priority);688 existing.type = yieldNode.value;689 existing.return = returnFiber;690 return existing;691 } else {692 deleteRemainingChildren(returnFiber, child);693 }694 }695 var created = createFiberFromYield(yieldNode, priority);696 created.type = yieldNode.value;697 created.return = returnFiber;698 return created;699 }700 function reconcileSinglePortal(returnFiber, currentFirstChild, portal, priority) {701 var key = portal.key;702 var child = currentFirstChild;703 while (child !== null) {704 if (child.key === key) {705 if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {706 deleteRemainingChildren(returnFiber, child.sibling);707 var existing = useFiber(child, priority);708 existing.pendingProps = portal.children || [];709 existing.return = returnFiber;710 return existing;711 } else {712 deleteRemainingChildren(returnFiber, child);713 break;714 }715 } else {716 deleteChild(returnFiber, child);717 }718 child = child.sibling;719 }720 var created = createFiberFromPortal(portal, priority);721 created.return = returnFiber;722 return created;723 }724 function reconcileChildFibers(returnFiber, currentFirstChild, newChild, priority) {725 var disableNewFiberFeatures = ReactFeatureFlags.disableNewFiberFeatures;726 var isObject = typeof newChild === 'object' && newChild !== null;727 if (isObject) {728 if (disableNewFiberFeatures) {729 switch (newChild.$$typeof) {730 case REACT_ELEMENT_TYPE:731 return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, priority));732 case REACT_PORTAL_TYPE:733 return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, priority));734 }735 } else {736 switch (newChild.$$typeof) {737 case REACT_ELEMENT_TYPE:738 return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, priority));739 case REACT_COROUTINE_TYPE:740 return placeSingleChild(reconcileSingleCoroutine(returnFiber, currentFirstChild, newChild, priority));741 case REACT_YIELD_TYPE:742 return placeSingleChild(reconcileSingleYield(returnFiber, currentFirstChild, newChild, priority));743 case REACT_PORTAL_TYPE:744 return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, priority));745 }746 }747 }748 if (disableNewFiberFeatures) {749 switch (returnFiber.tag) {750 case ClassComponent:751 {752 if (__DEV__) {753 var instance = returnFiber.stateNode;754 if (instance.render._isMockFunction && typeof newChild === 'undefined') {755 break;756 }757 }758 var Component = returnFiber.type;759 invariant(newChild === null || newChild === false, '%s.render(): A valid React element (or null) must be returned. ' + 'You may have returned undefined, an array or some other ' + 'invalid object.', Component.displayName || Component.name || 'Component');760 break;761 }762 case FunctionalComponent:763 {764 var _Component = returnFiber.type;765 invariant(newChild === null || newChild === false, '%s(...): A valid React element (or null) must be returned. ' + 'You may have returned undefined, an array or some other ' + 'invalid object.', _Component.displayName || _Component.name || 'Component');766 break;767 }768 }769 }770 if (typeof newChild === 'string' || typeof newChild === 'number') {771 return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, priority));772 }773 if (isArray(newChild)) {774 return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, priority);775 }776 if (getIteratorFn(newChild)) {777 return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, priority);778 }779 if (isObject) {780 throwOnInvalidObjectType(returnFiber, newChild);781 }782 if (!disableNewFiberFeatures && typeof newChild === 'undefined') {783 switch (returnFiber.tag) {784 case ClassComponent:785 {...

Full Screen

Full Screen

ce6df42c5b933ee2ca14358e199c7078c8e06aReactChildFiber.js

Source:ce6df42c5b933ee2ca14358e199c7078c8e06aReactChildFiber.js Github

copy

Full Screen

...165 newFiber.effectTag = Placement;166 return lastPlacedIndex;167 }168 }169 function placeSingleChild(newFiber) {170 if (shouldTrackSideEffects && newFiber.alternate === null) {171 newFiber.effectTag = Placement;172 }173 return newFiber;174 }175 function updateTextNode(returnFiber, current, textContent, priority) {176 if (current === null || current.tag !== HostText) {177 var created = createFiberFromText(textContent, priority);178 created.return = returnFiber;179 return created;180 } else {181 var existing = useFiber(current, priority);182 existing.pendingProps = textContent;183 existing.return = returnFiber;184 return existing;185 }186 }187 function updateElement(returnFiber, current, element, priority) {188 if (current === null || current.type !== element.type) {189 var created = createFiberFromElement(element, priority);190 created.ref = coerceRef(current, element);191 created.return = returnFiber;192 return created;193 } else {194 var existing = useFiber(current, priority);195 existing.ref = coerceRef(current, element);196 existing.pendingProps = element.props;197 existing.return = returnFiber;198 if (__DEV__) {199 existing._debugSource = element._source;200 existing._debugOwner = element._owner;201 }202 return existing;203 }204 }205 function updateCoroutine(returnFiber, current, coroutine, priority) {206 if (current === null || current.tag !== CoroutineComponent) {207 var created = createFiberFromCoroutine(coroutine, priority);208 created.return = returnFiber;209 return created;210 } else {211 var existing = useFiber(current, priority);212 existing.pendingProps = coroutine;213 existing.return = returnFiber;214 return existing;215 }216 }217 function updateYield(returnFiber, current, yieldNode, priority) {218 if (current === null || current.tag !== YieldComponent) {219 var created = createFiberFromYield(yieldNode, priority);220 created.type = yieldNode.value;221 created.return = returnFiber;222 return created;223 } else {224 var existing = useFiber(current, priority);225 existing.type = yieldNode.value;226 existing.return = returnFiber;227 return existing;228 }229 }230 function updatePortal(returnFiber, current, portal, priority) {231 if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {232 var created = createFiberFromPortal(portal, priority);233 created.return = returnFiber;234 return created;235 } else {236 var existing = useFiber(current, priority);237 existing.pendingProps = portal.children || [];238 existing.return = returnFiber;239 return existing;240 }241 }242 function updateFragment(returnFiber, current, fragment, priority) {243 if (current === null || current.tag !== Fragment) {244 var created = createFiberFromFragment(fragment, priority);245 created.return = returnFiber;246 return created;247 } else {248 var existing = useFiber(current, priority);249 existing.pendingProps = fragment;250 existing.return = returnFiber;251 return existing;252 }253 }254 function createChild(returnFiber, newChild, priority) {255 if (typeof newChild === 'string' || typeof newChild === 'number') {256 var created = createFiberFromText('' + newChild, priority);257 created.return = returnFiber;258 return created;259 }260 if (typeof newChild === 'object' && newChild !== null) {261 switch (newChild.$$typeof) {262 case REACT_ELEMENT_TYPE:263 {264 var _created = createFiberFromElement(newChild, priority);265 _created.ref = coerceRef(null, newChild);266 _created.return = returnFiber;267 return _created;268 }269 case REACT_COROUTINE_TYPE:270 {271 var _created2 = createFiberFromCoroutine(newChild, priority);272 _created2.return = returnFiber;273 return _created2;274 }275 case REACT_YIELD_TYPE:276 {277 var _created3 = createFiberFromYield(newChild, priority);278 _created3.type = newChild.value;279 _created3.return = returnFiber;280 return _created3;281 }282 case REACT_PORTAL_TYPE:283 {284 var _created4 = createFiberFromPortal(newChild, priority);285 _created4.return = returnFiber;286 return _created4;287 }288 }289 if (isArray(newChild) || getIteratorFn(newChild)) {290 var _created5 = createFiberFromFragment(newChild, priority);291 _created5.return = returnFiber;292 return _created5;293 }294 throwOnInvalidObjectType(returnFiber, newChild);295 }296 return null;297 }298 function updateSlot(returnFiber, oldFiber, newChild, priority) {299 var key = oldFiber !== null ? oldFiber.key : null;300 if (typeof newChild === 'string' || typeof newChild === 'number') {301 if (key !== null) {302 return null;303 }304 return updateTextNode(returnFiber, oldFiber, '' + newChild, priority);305 }306 if (typeof newChild === 'object' && newChild !== null) {307 switch (newChild.$$typeof) {308 case REACT_ELEMENT_TYPE:309 {310 if (newChild.key === key) {311 return updateElement(returnFiber, oldFiber, newChild, priority);312 } else {313 return null;314 }315 }316 case REACT_COROUTINE_TYPE:317 {318 if (newChild.key === key) {319 return updateCoroutine(returnFiber, oldFiber, newChild, priority);320 } else {321 return null;322 }323 }324 case REACT_YIELD_TYPE:325 {326 if (key === null) {327 return updateYield(returnFiber, oldFiber, newChild, priority);328 } else {329 return null;330 }331 }332 case REACT_PORTAL_TYPE:333 {334 if (newChild.key === key) {335 return updatePortal(returnFiber, oldFiber, newChild, priority);336 } else {337 return null;338 }339 }340 }341 if (isArray(newChild) || getIteratorFn(newChild)) {342 if (key !== null) {343 return null;344 }345 return updateFragment(returnFiber, oldFiber, newChild, priority);346 }347 throwOnInvalidObjectType(returnFiber, newChild);348 }349 return null;350 }351 function updateFromMap(existingChildren, returnFiber, newIdx, newChild, priority) {352 if (typeof newChild === 'string' || typeof newChild === 'number') {353 var matchedFiber = existingChildren.get(newIdx) || null;354 return updateTextNode(returnFiber, matchedFiber, '' + newChild, priority);355 }356 if (typeof newChild === 'object' && newChild !== null) {357 switch (newChild.$$typeof) {358 case REACT_ELEMENT_TYPE:359 {360 var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;361 return updateElement(returnFiber, _matchedFiber, newChild, priority);362 }363 case REACT_COROUTINE_TYPE:364 {365 var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;366 return updateCoroutine(returnFiber, _matchedFiber2, newChild, priority);367 }368 case REACT_YIELD_TYPE:369 {370 var _matchedFiber3 = existingChildren.get(newIdx) || null;371 return updateYield(returnFiber, _matchedFiber3, newChild, priority);372 }373 case REACT_PORTAL_TYPE:374 {375 var _matchedFiber4 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;376 return updatePortal(returnFiber, _matchedFiber4, newChild, priority);377 }378 }379 if (isArray(newChild) || getIteratorFn(newChild)) {380 var _matchedFiber5 = existingChildren.get(newIdx) || null;381 return updateFragment(returnFiber, _matchedFiber5, newChild, priority);382 }383 throwOnInvalidObjectType(returnFiber, newChild);384 }385 return null;386 }387 function warnOnDuplicateKey(child, knownKeys) {388 if (__DEV__) {389 if (typeof child !== 'object' || child === null) {390 return knownKeys;391 }392 switch (child.$$typeof) {393 case REACT_ELEMENT_TYPE:394 case REACT_COROUTINE_TYPE:395 case REACT_PORTAL_TYPE:396 var key = child.key;397 if (typeof key !== 'string') {398 break;399 }400 if (knownKeys === null) {401 knownKeys = new Set();402 knownKeys.add(key);403 break;404 }405 if (!knownKeys.has(key)) {406 knownKeys.add(key);407 break;408 }409 warning(false, 'Encountered two children with the same key, ' + '`%s`. Child keys must be unique; when two children share a key, ' + 'only the first child will be used.%s', key, getCurrentFiberStackAddendum());410 break;411 default:412 break;413 }414 }415 return knownKeys;416 }417 function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, priority) {418 if (__DEV__) {419 var knownKeys = null;420 for (var i = 0; i < newChildren.length; i++) {421 var child = newChildren[i];422 knownKeys = warnOnDuplicateKey(child, knownKeys);423 }424 }425 var resultingFirstChild = null;426 var previousNewFiber = null;427 var oldFiber = currentFirstChild;428 var lastPlacedIndex = 0;429 var newIdx = 0;430 var nextOldFiber = null;431 for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {432 if (oldFiber.index > newIdx) {433 nextOldFiber = oldFiber;434 oldFiber = null;435 } else {436 nextOldFiber = oldFiber.sibling;437 }438 var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], priority);439 if (newFiber === null) {440 if (oldFiber === null) {441 oldFiber = nextOldFiber;442 }443 break;444 }445 if (shouldTrackSideEffects) {446 if (oldFiber && newFiber.alternate === null) {447 deleteChild(returnFiber, oldFiber);448 }449 }450 lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);451 if (previousNewFiber === null) {452 resultingFirstChild = newFiber;453 } else {454 previousNewFiber.sibling = newFiber;455 }456 previousNewFiber = newFiber;457 oldFiber = nextOldFiber;458 }459 if (newIdx === newChildren.length) {460 deleteRemainingChildren(returnFiber, oldFiber);461 return resultingFirstChild;462 }463 if (oldFiber === null) {464 for (; newIdx < newChildren.length; newIdx++) {465 var _newFiber = createChild(returnFiber, newChildren[newIdx], priority);466 if (!_newFiber) {467 continue;468 }469 lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);470 if (previousNewFiber === null) {471 resultingFirstChild = _newFiber;472 } else {473 previousNewFiber.sibling = _newFiber;474 }475 previousNewFiber = _newFiber;476 }477 return resultingFirstChild;478 }479 var existingChildren = mapRemainingChildren(returnFiber, oldFiber);480 for (; newIdx < newChildren.length; newIdx++) {481 var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], priority);482 if (_newFiber2) {483 if (shouldTrackSideEffects) {484 if (_newFiber2.alternate !== null) {485 existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);486 }487 }488 lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);489 if (previousNewFiber === null) {490 resultingFirstChild = _newFiber2;491 } else {492 previousNewFiber.sibling = _newFiber2;493 }494 previousNewFiber = _newFiber2;495 }496 }497 if (shouldTrackSideEffects) {498 existingChildren.forEach(function (child) {499 return deleteChild(returnFiber, child);500 });501 }502 return resultingFirstChild;503 }504 function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, priority) {505 var iteratorFn = getIteratorFn(newChildrenIterable);506 invariant(typeof iteratorFn === 'function', 'An object is not an iterable. This error is likely caused by a bug in ' + 'React. Please file an issue.');507 if (__DEV__) {508 if (typeof newChildrenIterable.entries === 'function') {509 var possibleMap = newChildrenIterable;510 if (possibleMap.entries === iteratorFn) {511 var mapsAsChildrenAddendum = '';512 var owner = ReactCurrentOwner.owner || returnFiber._debugOwner;513 if (owner && typeof owner.tag === 'number') {514 var mapsAsChildrenOwnerName = getComponentName(owner);515 if (mapsAsChildrenOwnerName) {516 mapsAsChildrenAddendum = '\n\nCheck the render method of `' + mapsAsChildrenOwnerName + '`.';517 }518 }519 warning(didWarnAboutMaps, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.%s', mapsAsChildrenAddendum);520 didWarnAboutMaps = true;521 }522 }523 var _newChildren = iteratorFn.call(newChildrenIterable);524 if (_newChildren) {525 var knownKeys = null;526 var _step = _newChildren.next();527 for (; !_step.done; _step = _newChildren.next()) {528 var child = _step.value;529 knownKeys = warnOnDuplicateKey(child, knownKeys);530 }531 }532 }533 var newChildren = iteratorFn.call(newChildrenIterable);534 invariant(newChildren != null, 'An iterable object provided no iterator.');535 var resultingFirstChild = null;536 var previousNewFiber = null;537 var oldFiber = currentFirstChild;538 var lastPlacedIndex = 0;539 var newIdx = 0;540 var nextOldFiber = null;541 var step = newChildren.next();542 for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {543 if (oldFiber.index > newIdx) {544 nextOldFiber = oldFiber;545 oldFiber = null;546 } else {547 nextOldFiber = oldFiber.sibling;548 }549 var newFiber = updateSlot(returnFiber, oldFiber, step.value, priority);550 if (newFiber === null) {551 if (!oldFiber) {552 oldFiber = nextOldFiber;553 }554 break;555 }556 if (shouldTrackSideEffects) {557 if (oldFiber && newFiber.alternate === null) {558 deleteChild(returnFiber, oldFiber);559 }560 }561 lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);562 if (previousNewFiber === null) {563 resultingFirstChild = newFiber;564 } else {565 previousNewFiber.sibling = newFiber;566 }567 previousNewFiber = newFiber;568 oldFiber = nextOldFiber;569 }570 if (step.done) {571 deleteRemainingChildren(returnFiber, oldFiber);572 return resultingFirstChild;573 }574 if (oldFiber === null) {575 for (; !step.done; newIdx++, step = newChildren.next()) {576 var _newFiber3 = createChild(returnFiber, step.value, priority);577 if (_newFiber3 === null) {578 continue;579 }580 lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);581 if (previousNewFiber === null) {582 resultingFirstChild = _newFiber3;583 } else {584 previousNewFiber.sibling = _newFiber3;585 }586 previousNewFiber = _newFiber3;587 }588 return resultingFirstChild;589 }590 var existingChildren = mapRemainingChildren(returnFiber, oldFiber);591 for (; !step.done; newIdx++, step = newChildren.next()) {592 var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, priority);593 if (_newFiber4 !== null) {594 if (shouldTrackSideEffects) {595 if (_newFiber4.alternate !== null) {596 existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);597 }598 }599 lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);600 if (previousNewFiber === null) {601 resultingFirstChild = _newFiber4;602 } else {603 previousNewFiber.sibling = _newFiber4;604 }605 previousNewFiber = _newFiber4;606 }607 }608 if (shouldTrackSideEffects) {609 existingChildren.forEach(function (child) {610 return deleteChild(returnFiber, child);611 });612 }613 return resultingFirstChild;614 }615 function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, priority) {616 if (currentFirstChild !== null && currentFirstChild.tag === HostText) {617 deleteRemainingChildren(returnFiber, currentFirstChild.sibling);618 var existing = useFiber(currentFirstChild, priority);619 existing.pendingProps = textContent;620 existing.return = returnFiber;621 return existing;622 }623 deleteRemainingChildren(returnFiber, currentFirstChild);624 var created = createFiberFromText(textContent, priority);625 created.return = returnFiber;626 return created;627 }628 function reconcileSingleElement(returnFiber, currentFirstChild, element, priority) {629 var key = element.key;630 var child = currentFirstChild;631 while (child !== null) {632 if (child.key === key) {633 if (child.type === element.type) {634 deleteRemainingChildren(returnFiber, child.sibling);635 var existing = useFiber(child, priority);636 existing.ref = coerceRef(child, element);637 existing.pendingProps = element.props;638 existing.return = returnFiber;639 if (__DEV__) {640 existing._debugSource = element._source;641 existing._debugOwner = element._owner;642 }643 return existing;644 } else {645 deleteRemainingChildren(returnFiber, child);646 break;647 }648 } else {649 deleteChild(returnFiber, child);650 }651 child = child.sibling;652 }653 var created = createFiberFromElement(element, priority);654 created.ref = coerceRef(currentFirstChild, element);655 created.return = returnFiber;656 return created;657 }658 function reconcileSingleCoroutine(returnFiber, currentFirstChild, coroutine, priority) {659 var key = coroutine.key;660 var child = currentFirstChild;661 while (child !== null) {662 if (child.key === key) {663 if (child.tag === CoroutineComponent) {664 deleteRemainingChildren(returnFiber, child.sibling);665 var existing = useFiber(child, priority);666 existing.pendingProps = coroutine;667 existing.return = returnFiber;668 return existing;669 } else {670 deleteRemainingChildren(returnFiber, child);671 break;672 }673 } else {674 deleteChild(returnFiber, child);675 }676 child = child.sibling;677 }678 var created = createFiberFromCoroutine(coroutine, priority);679 created.return = returnFiber;680 return created;681 }682 function reconcileSingleYield(returnFiber, currentFirstChild, yieldNode, priority) {683 var child = currentFirstChild;684 if (child !== null) {685 if (child.tag === YieldComponent) {686 deleteRemainingChildren(returnFiber, child.sibling);687 var existing = useFiber(child, priority);688 existing.type = yieldNode.value;689 existing.return = returnFiber;690 return existing;691 } else {692 deleteRemainingChildren(returnFiber, child);693 }694 }695 var created = createFiberFromYield(yieldNode, priority);696 created.type = yieldNode.value;697 created.return = returnFiber;698 return created;699 }700 function reconcileSinglePortal(returnFiber, currentFirstChild, portal, priority) {701 var key = portal.key;702 var child = currentFirstChild;703 while (child !== null) {704 if (child.key === key) {705 if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {706 deleteRemainingChildren(returnFiber, child.sibling);707 var existing = useFiber(child, priority);708 existing.pendingProps = portal.children || [];709 existing.return = returnFiber;710 return existing;711 } else {712 deleteRemainingChildren(returnFiber, child);713 break;714 }715 } else {716 deleteChild(returnFiber, child);717 }718 child = child.sibling;719 }720 var created = createFiberFromPortal(portal, priority);721 created.return = returnFiber;722 return created;723 }724 function reconcileChildFibers(returnFiber, currentFirstChild, newChild, priority) {725 var disableNewFiberFeatures = ReactFeatureFlags.disableNewFiberFeatures;726 var isObject = typeof newChild === 'object' && newChild !== null;727 if (isObject) {728 if (disableNewFiberFeatures) {729 switch (newChild.$$typeof) {730 case REACT_ELEMENT_TYPE:731 return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, priority));732 case REACT_PORTAL_TYPE:733 return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, priority));734 }735 } else {736 switch (newChild.$$typeof) {737 case REACT_ELEMENT_TYPE:738 return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, priority));739 case REACT_COROUTINE_TYPE:740 return placeSingleChild(reconcileSingleCoroutine(returnFiber, currentFirstChild, newChild, priority));741 case REACT_YIELD_TYPE:742 return placeSingleChild(reconcileSingleYield(returnFiber, currentFirstChild, newChild, priority));743 case REACT_PORTAL_TYPE:744 return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, priority));745 }746 }747 }748 if (disableNewFiberFeatures) {749 switch (returnFiber.tag) {750 case ClassComponent:751 {752 if (__DEV__) {753 var instance = returnFiber.stateNode;754 if (instance.render._isMockFunction && typeof newChild === 'undefined') {755 break;756 }757 }758 var Component = returnFiber.type;759 invariant(newChild === null || newChild === false, '%s.render(): A valid React element (or null) must be returned. ' + 'You may have returned undefined, an array or some other ' + 'invalid object.', Component.displayName || Component.name || 'Component');760 break;761 }762 case FunctionalComponent:763 {764 var _Component = returnFiber.type;765 invariant(newChild === null || newChild === false, '%s(...): A valid React element (or null) must be returned. ' + 'You may have returned undefined, an array or some other ' + 'invalid object.', _Component.displayName || _Component.name || 'Component');766 break;767 }768 }769 }770 if (typeof newChild === 'string' || typeof newChild === 'number') {771 return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, priority));772 }773 if (isArray(newChild)) {774 return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, priority);775 }776 if (getIteratorFn(newChild)) {777 return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, priority);778 }779 if (isObject) {780 throwOnInvalidObjectType(returnFiber, newChild);781 }782 if (!disableNewFiberFeatures && typeof newChild === 'undefined') {783 switch (returnFiber.tag) {784 case ClassComponent:785 {...

Full Screen

Full Screen

b81b7ed169eab82c9b5e9419bb967395a5c0e8ReactChildFiber.js

Source:b81b7ed169eab82c9b5e9419bb967395a5c0e8ReactChildFiber.js Github

copy

Full Screen

...165 newFiber.effectTag = Placement;166 return lastPlacedIndex;167 }168 }169 function placeSingleChild(newFiber) {170 if (shouldTrackSideEffects && newFiber.alternate === null) {171 newFiber.effectTag = Placement;172 }173 return newFiber;174 }175 function updateTextNode(returnFiber, current, textContent, priority) {176 if (current === null || current.tag !== HostText) {177 var created = createFiberFromText(textContent, priority);178 created.return = returnFiber;179 return created;180 } else {181 var existing = useFiber(current, priority);182 existing.pendingProps = textContent;183 existing.return = returnFiber;184 return existing;185 }186 }187 function updateElement(returnFiber, current, element, priority) {188 if (current === null || current.type !== element.type) {189 var created = createFiberFromElement(element, priority);190 created.ref = coerceRef(current, element);191 created.return = returnFiber;192 return created;193 } else {194 var existing = useFiber(current, priority);195 existing.ref = coerceRef(current, element);196 existing.pendingProps = element.props;197 existing.return = returnFiber;198 if (__DEV__) {199 existing._debugSource = element._source;200 existing._debugOwner = element._owner;201 }202 return existing;203 }204 }205 function updateCoroutine(returnFiber, current, coroutine, priority) {206 if (current === null || current.tag !== CoroutineComponent) {207 var created = createFiberFromCoroutine(coroutine, priority);208 created.return = returnFiber;209 return created;210 } else {211 var existing = useFiber(current, priority);212 existing.pendingProps = coroutine;213 existing.return = returnFiber;214 return existing;215 }216 }217 function updateYield(returnFiber, current, yieldNode, priority) {218 if (current === null || current.tag !== YieldComponent) {219 var created = createFiberFromYield(yieldNode, priority);220 created.type = yieldNode.value;221 created.return = returnFiber;222 return created;223 } else {224 var existing = useFiber(current, priority);225 existing.type = yieldNode.value;226 existing.return = returnFiber;227 return existing;228 }229 }230 function updatePortal(returnFiber, current, portal, priority) {231 if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {232 var created = createFiberFromPortal(portal, priority);233 created.return = returnFiber;234 return created;235 } else {236 var existing = useFiber(current, priority);237 existing.pendingProps = portal.children || [];238 existing.return = returnFiber;239 return existing;240 }241 }242 function updateFragment(returnFiber, current, fragment, priority) {243 if (current === null || current.tag !== Fragment) {244 var created = createFiberFromFragment(fragment, priority);245 created.return = returnFiber;246 return created;247 } else {248 var existing = useFiber(current, priority);249 existing.pendingProps = fragment;250 existing.return = returnFiber;251 return existing;252 }253 }254 function createChild(returnFiber, newChild, priority) {255 if (typeof newChild === 'string' || typeof newChild === 'number') {256 var created = createFiberFromText('' + newChild, priority);257 created.return = returnFiber;258 return created;259 }260 if (typeof newChild === 'object' && newChild !== null) {261 switch (newChild.$$typeof) {262 case REACT_ELEMENT_TYPE:263 {264 var _created = createFiberFromElement(newChild, priority);265 _created.ref = coerceRef(null, newChild);266 _created.return = returnFiber;267 return _created;268 }269 case REACT_COROUTINE_TYPE:270 {271 var _created2 = createFiberFromCoroutine(newChild, priority);272 _created2.return = returnFiber;273 return _created2;274 }275 case REACT_YIELD_TYPE:276 {277 var _created3 = createFiberFromYield(newChild, priority);278 _created3.type = newChild.value;279 _created3.return = returnFiber;280 return _created3;281 }282 case REACT_PORTAL_TYPE:283 {284 var _created4 = createFiberFromPortal(newChild, priority);285 _created4.return = returnFiber;286 return _created4;287 }288 }289 if (isArray(newChild) || getIteratorFn(newChild)) {290 var _created5 = createFiberFromFragment(newChild, priority);291 _created5.return = returnFiber;292 return _created5;293 }294 throwOnInvalidObjectType(returnFiber, newChild);295 }296 return null;297 }298 function updateSlot(returnFiber, oldFiber, newChild, priority) {299 var key = oldFiber !== null ? oldFiber.key : null;300 if (typeof newChild === 'string' || typeof newChild === 'number') {301 if (key !== null) {302 return null;303 }304 return updateTextNode(returnFiber, oldFiber, '' + newChild, priority);305 }306 if (typeof newChild === 'object' && newChild !== null) {307 switch (newChild.$$typeof) {308 case REACT_ELEMENT_TYPE:309 {310 if (newChild.key === key) {311 return updateElement(returnFiber, oldFiber, newChild, priority);312 } else {313 return null;314 }315 }316 case REACT_COROUTINE_TYPE:317 {318 if (newChild.key === key) {319 return updateCoroutine(returnFiber, oldFiber, newChild, priority);320 } else {321 return null;322 }323 }324 case REACT_YIELD_TYPE:325 {326 if (key === null) {327 return updateYield(returnFiber, oldFiber, newChild, priority);328 } else {329 return null;330 }331 }332 case REACT_PORTAL_TYPE:333 {334 if (newChild.key === key) {335 return updatePortal(returnFiber, oldFiber, newChild, priority);336 } else {337 return null;338 }339 }340 }341 if (isArray(newChild) || getIteratorFn(newChild)) {342 if (key !== null) {343 return null;344 }345 return updateFragment(returnFiber, oldFiber, newChild, priority);346 }347 throwOnInvalidObjectType(returnFiber, newChild);348 }349 return null;350 }351 function updateFromMap(existingChildren, returnFiber, newIdx, newChild, priority) {352 if (typeof newChild === 'string' || typeof newChild === 'number') {353 var matchedFiber = existingChildren.get(newIdx) || null;354 return updateTextNode(returnFiber, matchedFiber, '' + newChild, priority);355 }356 if (typeof newChild === 'object' && newChild !== null) {357 switch (newChild.$$typeof) {358 case REACT_ELEMENT_TYPE:359 {360 var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;361 return updateElement(returnFiber, _matchedFiber, newChild, priority);362 }363 case REACT_COROUTINE_TYPE:364 {365 var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;366 return updateCoroutine(returnFiber, _matchedFiber2, newChild, priority);367 }368 case REACT_YIELD_TYPE:369 {370 var _matchedFiber3 = existingChildren.get(newIdx) || null;371 return updateYield(returnFiber, _matchedFiber3, newChild, priority);372 }373 case REACT_PORTAL_TYPE:374 {375 var _matchedFiber4 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;376 return updatePortal(returnFiber, _matchedFiber4, newChild, priority);377 }378 }379 if (isArray(newChild) || getIteratorFn(newChild)) {380 var _matchedFiber5 = existingChildren.get(newIdx) || null;381 return updateFragment(returnFiber, _matchedFiber5, newChild, priority);382 }383 throwOnInvalidObjectType(returnFiber, newChild);384 }385 return null;386 }387 function warnOnDuplicateKey(child, knownKeys) {388 if (__DEV__) {389 if (typeof child !== 'object' || child === null) {390 return knownKeys;391 }392 switch (child.$$typeof) {393 case REACT_ELEMENT_TYPE:394 case REACT_COROUTINE_TYPE:395 case REACT_PORTAL_TYPE:396 var key = child.key;397 if (typeof key !== 'string') {398 break;399 }400 if (knownKeys === null) {401 knownKeys = new Set();402 knownKeys.add(key);403 break;404 }405 if (!knownKeys.has(key)) {406 knownKeys.add(key);407 break;408 }409 warning(false, 'Encountered two children with the same key, ' + '`%s`. Child keys must be unique; when two children share a key, ' + 'only the first child will be used.%s', key, getCurrentFiberStackAddendum());410 break;411 default:412 break;413 }414 }415 return knownKeys;416 }417 function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, priority) {418 if (__DEV__) {419 var knownKeys = null;420 for (var i = 0; i < newChildren.length; i++) {421 var child = newChildren[i];422 knownKeys = warnOnDuplicateKey(child, knownKeys);423 }424 }425 var resultingFirstChild = null;426 var previousNewFiber = null;427 var oldFiber = currentFirstChild;428 var lastPlacedIndex = 0;429 var newIdx = 0;430 var nextOldFiber = null;431 for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {432 if (oldFiber.index > newIdx) {433 nextOldFiber = oldFiber;434 oldFiber = null;435 } else {436 nextOldFiber = oldFiber.sibling;437 }438 var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], priority);439 if (newFiber === null) {440 if (oldFiber === null) {441 oldFiber = nextOldFiber;442 }443 break;444 }445 if (shouldTrackSideEffects) {446 if (oldFiber && newFiber.alternate === null) {447 deleteChild(returnFiber, oldFiber);448 }449 }450 lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);451 if (previousNewFiber === null) {452 resultingFirstChild = newFiber;453 } else {454 previousNewFiber.sibling = newFiber;455 }456 previousNewFiber = newFiber;457 oldFiber = nextOldFiber;458 }459 if (newIdx === newChildren.length) {460 deleteRemainingChildren(returnFiber, oldFiber);461 return resultingFirstChild;462 }463 if (oldFiber === null) {464 for (; newIdx < newChildren.length; newIdx++) {465 var _newFiber = createChild(returnFiber, newChildren[newIdx], priority);466 if (!_newFiber) {467 continue;468 }469 lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);470 if (previousNewFiber === null) {471 resultingFirstChild = _newFiber;472 } else {473 previousNewFiber.sibling = _newFiber;474 }475 previousNewFiber = _newFiber;476 }477 return resultingFirstChild;478 }479 var existingChildren = mapRemainingChildren(returnFiber, oldFiber);480 for (; newIdx < newChildren.length; newIdx++) {481 var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], priority);482 if (_newFiber2) {483 if (shouldTrackSideEffects) {484 if (_newFiber2.alternate !== null) {485 existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);486 }487 }488 lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);489 if (previousNewFiber === null) {490 resultingFirstChild = _newFiber2;491 } else {492 previousNewFiber.sibling = _newFiber2;493 }494 previousNewFiber = _newFiber2;495 }496 }497 if (shouldTrackSideEffects) {498 existingChildren.forEach(function (child) {499 return deleteChild(returnFiber, child);500 });501 }502 return resultingFirstChild;503 }504 function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, priority) {505 var iteratorFn = getIteratorFn(newChildrenIterable);506 invariant(typeof iteratorFn === 'function', 'An object is not an iterable. This error is likely caused by a bug in ' + 'React. Please file an issue.');507 if (__DEV__) {508 if (typeof newChildrenIterable.entries === 'function') {509 var possibleMap = newChildrenIterable;510 if (possibleMap.entries === iteratorFn) {511 var mapsAsChildrenAddendum = '';512 var owner = ReactCurrentOwner.owner || returnFiber._debugOwner;513 if (owner && typeof owner.tag === 'number') {514 var mapsAsChildrenOwnerName = getComponentName(owner);515 if (mapsAsChildrenOwnerName) {516 mapsAsChildrenAddendum = '\n\nCheck the render method of `' + mapsAsChildrenOwnerName + '`.';517 }518 }519 warning(didWarnAboutMaps, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.%s', mapsAsChildrenAddendum);520 didWarnAboutMaps = true;521 }522 }523 var _newChildren = iteratorFn.call(newChildrenIterable);524 if (_newChildren) {525 var knownKeys = null;526 var _step = _newChildren.next();527 for (; !_step.done; _step = _newChildren.next()) {528 var child = _step.value;529 knownKeys = warnOnDuplicateKey(child, knownKeys);530 }531 }532 }533 var newChildren = iteratorFn.call(newChildrenIterable);534 invariant(newChildren != null, 'An iterable object provided no iterator.');535 var resultingFirstChild = null;536 var previousNewFiber = null;537 var oldFiber = currentFirstChild;538 var lastPlacedIndex = 0;539 var newIdx = 0;540 var nextOldFiber = null;541 var step = newChildren.next();542 for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {543 if (oldFiber.index > newIdx) {544 nextOldFiber = oldFiber;545 oldFiber = null;546 } else {547 nextOldFiber = oldFiber.sibling;548 }549 var newFiber = updateSlot(returnFiber, oldFiber, step.value, priority);550 if (newFiber === null) {551 if (!oldFiber) {552 oldFiber = nextOldFiber;553 }554 break;555 }556 if (shouldTrackSideEffects) {557 if (oldFiber && newFiber.alternate === null) {558 deleteChild(returnFiber, oldFiber);559 }560 }561 lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);562 if (previousNewFiber === null) {563 resultingFirstChild = newFiber;564 } else {565 previousNewFiber.sibling = newFiber;566 }567 previousNewFiber = newFiber;568 oldFiber = nextOldFiber;569 }570 if (step.done) {571 deleteRemainingChildren(returnFiber, oldFiber);572 return resultingFirstChild;573 }574 if (oldFiber === null) {575 for (; !step.done; newIdx++, step = newChildren.next()) {576 var _newFiber3 = createChild(returnFiber, step.value, priority);577 if (_newFiber3 === null) {578 continue;579 }580 lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);581 if (previousNewFiber === null) {582 resultingFirstChild = _newFiber3;583 } else {584 previousNewFiber.sibling = _newFiber3;585 }586 previousNewFiber = _newFiber3;587 }588 return resultingFirstChild;589 }590 var existingChildren = mapRemainingChildren(returnFiber, oldFiber);591 for (; !step.done; newIdx++, step = newChildren.next()) {592 var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, priority);593 if (_newFiber4 !== null) {594 if (shouldTrackSideEffects) {595 if (_newFiber4.alternate !== null) {596 existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);597 }598 }599 lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);600 if (previousNewFiber === null) {601 resultingFirstChild = _newFiber4;602 } else {603 previousNewFiber.sibling = _newFiber4;604 }605 previousNewFiber = _newFiber4;606 }607 }608 if (shouldTrackSideEffects) {609 existingChildren.forEach(function (child) {610 return deleteChild(returnFiber, child);611 });612 }613 return resultingFirstChild;614 }615 function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, priority) {616 if (currentFirstChild !== null && currentFirstChild.tag === HostText) {617 deleteRemainingChildren(returnFiber, currentFirstChild.sibling);618 var existing = useFiber(currentFirstChild, priority);619 existing.pendingProps = textContent;620 existing.return = returnFiber;621 return existing;622 }623 deleteRemainingChildren(returnFiber, currentFirstChild);624 var created = createFiberFromText(textContent, priority);625 created.return = returnFiber;626 return created;627 }628 function reconcileSingleElement(returnFiber, currentFirstChild, element, priority) {629 var key = element.key;630 var child = currentFirstChild;631 while (child !== null) {632 if (child.key === key) {633 if (child.type === element.type) {634 deleteRemainingChildren(returnFiber, child.sibling);635 var existing = useFiber(child, priority);636 existing.ref = coerceRef(child, element);637 existing.pendingProps = element.props;638 existing.return = returnFiber;639 if (__DEV__) {640 existing._debugSource = element._source;641 existing._debugOwner = element._owner;642 }643 return existing;644 } else {645 deleteRemainingChildren(returnFiber, child);646 break;647 }648 } else {649 deleteChild(returnFiber, child);650 }651 child = child.sibling;652 }653 var created = createFiberFromElement(element, priority);654 created.ref = coerceRef(currentFirstChild, element);655 created.return = returnFiber;656 return created;657 }658 function reconcileSingleCoroutine(returnFiber, currentFirstChild, coroutine, priority) {659 var key = coroutine.key;660 var child = currentFirstChild;661 while (child !== null) {662 if (child.key === key) {663 if (child.tag === CoroutineComponent) {664 deleteRemainingChildren(returnFiber, child.sibling);665 var existing = useFiber(child, priority);666 existing.pendingProps = coroutine;667 existing.return = returnFiber;668 return existing;669 } else {670 deleteRemainingChildren(returnFiber, child);671 break;672 }673 } else {674 deleteChild(returnFiber, child);675 }676 child = child.sibling;677 }678 var created = createFiberFromCoroutine(coroutine, priority);679 created.return = returnFiber;680 return created;681 }682 function reconcileSingleYield(returnFiber, currentFirstChild, yieldNode, priority) {683 var child = currentFirstChild;684 if (child !== null) {685 if (child.tag === YieldComponent) {686 deleteRemainingChildren(returnFiber, child.sibling);687 var existing = useFiber(child, priority);688 existing.type = yieldNode.value;689 existing.return = returnFiber;690 return existing;691 } else {692 deleteRemainingChildren(returnFiber, child);693 }694 }695 var created = createFiberFromYield(yieldNode, priority);696 created.type = yieldNode.value;697 created.return = returnFiber;698 return created;699 }700 function reconcileSinglePortal(returnFiber, currentFirstChild, portal, priority) {701 var key = portal.key;702 var child = currentFirstChild;703 while (child !== null) {704 if (child.key === key) {705 if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {706 deleteRemainingChildren(returnFiber, child.sibling);707 var existing = useFiber(child, priority);708 existing.pendingProps = portal.children || [];709 existing.return = returnFiber;710 return existing;711 } else {712 deleteRemainingChildren(returnFiber, child);713 break;714 }715 } else {716 deleteChild(returnFiber, child);717 }718 child = child.sibling;719 }720 var created = createFiberFromPortal(portal, priority);721 created.return = returnFiber;722 return created;723 }724 function reconcileChildFibers(returnFiber, currentFirstChild, newChild, priority) {725 var disableNewFiberFeatures = ReactFeatureFlags.disableNewFiberFeatures;726 var isObject = typeof newChild === 'object' && newChild !== null;727 if (isObject) {728 if (disableNewFiberFeatures) {729 switch (newChild.$$typeof) {730 case REACT_ELEMENT_TYPE:731 return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, priority));732 case REACT_PORTAL_TYPE:733 return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, priority));734 }735 } else {736 switch (newChild.$$typeof) {737 case REACT_ELEMENT_TYPE:738 return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, priority));739 case REACT_COROUTINE_TYPE:740 return placeSingleChild(reconcileSingleCoroutine(returnFiber, currentFirstChild, newChild, priority));741 case REACT_YIELD_TYPE:742 return placeSingleChild(reconcileSingleYield(returnFiber, currentFirstChild, newChild, priority));743 case REACT_PORTAL_TYPE:744 return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, priority));745 }746 }747 }748 if (disableNewFiberFeatures) {749 switch (returnFiber.tag) {750 case ClassComponent:751 {752 if (__DEV__) {753 var instance = returnFiber.stateNode;754 if (instance.render._isMockFunction && typeof newChild === 'undefined') {755 break;756 }757 }758 var Component = returnFiber.type;759 invariant(newChild === null || newChild === false, '%s.render(): A valid React element (or null) must be returned. ' + 'You may have returned undefined, an array or some other ' + 'invalid object.', Component.displayName || Component.name || 'Component');760 break;761 }762 case FunctionalComponent:763 {764 var _Component = returnFiber.type;765 invariant(newChild === null || newChild === false, '%s(...): A valid React element (or null) must be returned. ' + 'You may have returned undefined, an array or some other ' + 'invalid object.', _Component.displayName || _Component.name || 'Component');766 break;767 }768 }769 }770 if (typeof newChild === 'string' || typeof newChild === 'number') {771 return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, priority));772 }773 if (isArray(newChild)) {774 return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, priority);775 }776 if (getIteratorFn(newChild)) {777 return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, priority);778 }779 if (isObject) {780 throwOnInvalidObjectType(returnFiber, newChild);781 }782 if (!disableNewFiberFeatures && typeof newChild === 'undefined') {783 switch (returnFiber.tag) {784 case ClassComponent:785 {...

Full Screen

Full Screen

2777a7e15608de56c000ecbbdfa33c57bd5a43ReactChildFiber.js

Source:2777a7e15608de56c000ecbbdfa33c57bd5a43ReactChildFiber.js Github

copy

Full Screen

...165 newFiber.effectTag = Placement;166 return lastPlacedIndex;167 }168 }169 function placeSingleChild(newFiber) {170 if (shouldTrackSideEffects && newFiber.alternate === null) {171 newFiber.effectTag = Placement;172 }173 return newFiber;174 }175 function updateTextNode(returnFiber, current, textContent, priority) {176 if (current === null || current.tag !== HostText) {177 var created = createFiberFromText(textContent, priority);178 created.return = returnFiber;179 return created;180 } else {181 var existing = useFiber(current, priority);182 existing.pendingProps = textContent;183 existing.return = returnFiber;184 return existing;185 }186 }187 function updateElement(returnFiber, current, element, priority) {188 if (current === null || current.type !== element.type) {189 var created = createFiberFromElement(element, priority);190 created.ref = coerceRef(current, element);191 created.return = returnFiber;192 return created;193 } else {194 var existing = useFiber(current, priority);195 existing.ref = coerceRef(current, element);196 existing.pendingProps = element.props;197 existing.return = returnFiber;198 if (__DEV__) {199 existing._debugSource = element._source;200 existing._debugOwner = element._owner;201 }202 return existing;203 }204 }205 function updateCoroutine(returnFiber, current, coroutine, priority) {206 if (current === null || current.tag !== CoroutineComponent) {207 var created = createFiberFromCoroutine(coroutine, priority);208 created.return = returnFiber;209 return created;210 } else {211 var existing = useFiber(current, priority);212 existing.pendingProps = coroutine;213 existing.return = returnFiber;214 return existing;215 }216 }217 function updateYield(returnFiber, current, yieldNode, priority) {218 if (current === null || current.tag !== YieldComponent) {219 var created = createFiberFromYield(yieldNode, priority);220 created.type = yieldNode.value;221 created.return = returnFiber;222 return created;223 } else {224 var existing = useFiber(current, priority);225 existing.type = yieldNode.value;226 existing.return = returnFiber;227 return existing;228 }229 }230 function updatePortal(returnFiber, current, portal, priority) {231 if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {232 var created = createFiberFromPortal(portal, priority);233 created.return = returnFiber;234 return created;235 } else {236 var existing = useFiber(current, priority);237 existing.pendingProps = portal.children || [];238 existing.return = returnFiber;239 return existing;240 }241 }242 function updateFragment(returnFiber, current, fragment, priority) {243 if (current === null || current.tag !== Fragment) {244 var created = createFiberFromFragment(fragment, priority);245 created.return = returnFiber;246 return created;247 } else {248 var existing = useFiber(current, priority);249 existing.pendingProps = fragment;250 existing.return = returnFiber;251 return existing;252 }253 }254 function createChild(returnFiber, newChild, priority) {255 if (typeof newChild === 'string' || typeof newChild === 'number') {256 var created = createFiberFromText('' + newChild, priority);257 created.return = returnFiber;258 return created;259 }260 if (typeof newChild === 'object' && newChild !== null) {261 switch (newChild.$$typeof) {262 case REACT_ELEMENT_TYPE:263 {264 var _created = createFiberFromElement(newChild, priority);265 _created.ref = coerceRef(null, newChild);266 _created.return = returnFiber;267 return _created;268 }269 case REACT_COROUTINE_TYPE:270 {271 var _created2 = createFiberFromCoroutine(newChild, priority);272 _created2.return = returnFiber;273 return _created2;274 }275 case REACT_YIELD_TYPE:276 {277 var _created3 = createFiberFromYield(newChild, priority);278 _created3.type = newChild.value;279 _created3.return = returnFiber;280 return _created3;281 }282 case REACT_PORTAL_TYPE:283 {284 var _created4 = createFiberFromPortal(newChild, priority);285 _created4.return = returnFiber;286 return _created4;287 }288 }289 if (isArray(newChild) || getIteratorFn(newChild)) {290 var _created5 = createFiberFromFragment(newChild, priority);291 _created5.return = returnFiber;292 return _created5;293 }294 throwOnInvalidObjectType(returnFiber, newChild);295 }296 return null;297 }298 function updateSlot(returnFiber, oldFiber, newChild, priority) {299 var key = oldFiber !== null ? oldFiber.key : null;300 if (typeof newChild === 'string' || typeof newChild === 'number') {301 if (key !== null) {302 return null;303 }304 return updateTextNode(returnFiber, oldFiber, '' + newChild, priority);305 }306 if (typeof newChild === 'object' && newChild !== null) {307 switch (newChild.$$typeof) {308 case REACT_ELEMENT_TYPE:309 {310 if (newChild.key === key) {311 return updateElement(returnFiber, oldFiber, newChild, priority);312 } else {313 return null;314 }315 }316 case REACT_COROUTINE_TYPE:317 {318 if (newChild.key === key) {319 return updateCoroutine(returnFiber, oldFiber, newChild, priority);320 } else {321 return null;322 }323 }324 case REACT_YIELD_TYPE:325 {326 if (key === null) {327 return updateYield(returnFiber, oldFiber, newChild, priority);328 } else {329 return null;330 }331 }332 case REACT_PORTAL_TYPE:333 {334 if (newChild.key === key) {335 return updatePortal(returnFiber, oldFiber, newChild, priority);336 } else {337 return null;338 }339 }340 }341 if (isArray(newChild) || getIteratorFn(newChild)) {342 if (key !== null) {343 return null;344 }345 return updateFragment(returnFiber, oldFiber, newChild, priority);346 }347 throwOnInvalidObjectType(returnFiber, newChild);348 }349 return null;350 }351 function updateFromMap(existingChildren, returnFiber, newIdx, newChild, priority) {352 if (typeof newChild === 'string' || typeof newChild === 'number') {353 var matchedFiber = existingChildren.get(newIdx) || null;354 return updateTextNode(returnFiber, matchedFiber, '' + newChild, priority);355 }356 if (typeof newChild === 'object' && newChild !== null) {357 switch (newChild.$$typeof) {358 case REACT_ELEMENT_TYPE:359 {360 var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;361 return updateElement(returnFiber, _matchedFiber, newChild, priority);362 }363 case REACT_COROUTINE_TYPE:364 {365 var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;366 return updateCoroutine(returnFiber, _matchedFiber2, newChild, priority);367 }368 case REACT_YIELD_TYPE:369 {370 var _matchedFiber3 = existingChildren.get(newIdx) || null;371 return updateYield(returnFiber, _matchedFiber3, newChild, priority);372 }373 case REACT_PORTAL_TYPE:374 {375 var _matchedFiber4 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;376 return updatePortal(returnFiber, _matchedFiber4, newChild, priority);377 }378 }379 if (isArray(newChild) || getIteratorFn(newChild)) {380 var _matchedFiber5 = existingChildren.get(newIdx) || null;381 return updateFragment(returnFiber, _matchedFiber5, newChild, priority);382 }383 throwOnInvalidObjectType(returnFiber, newChild);384 }385 return null;386 }387 function warnOnDuplicateKey(child, knownKeys) {388 if (__DEV__) {389 if (typeof child !== 'object' || child === null) {390 return knownKeys;391 }392 switch (child.$$typeof) {393 case REACT_ELEMENT_TYPE:394 case REACT_COROUTINE_TYPE:395 case REACT_PORTAL_TYPE:396 var key = child.key;397 if (typeof key !== 'string') {398 break;399 }400 if (knownKeys === null) {401 knownKeys = new Set();402 knownKeys.add(key);403 break;404 }405 if (!knownKeys.has(key)) {406 knownKeys.add(key);407 break;408 }409 warning(false, 'Encountered two children with the same key, ' + '`%s`. Child keys must be unique; when two children share a key, ' + 'only the first child will be used.%s', key, getCurrentFiberStackAddendum());410 break;411 default:412 break;413 }414 }415 return knownKeys;416 }417 function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, priority) {418 if (__DEV__) {419 var knownKeys = null;420 for (var i = 0; i < newChildren.length; i++) {421 var child = newChildren[i];422 knownKeys = warnOnDuplicateKey(child, knownKeys);423 }424 }425 var resultingFirstChild = null;426 var previousNewFiber = null;427 var oldFiber = currentFirstChild;428 var lastPlacedIndex = 0;429 var newIdx = 0;430 var nextOldFiber = null;431 for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {432 if (oldFiber.index > newIdx) {433 nextOldFiber = oldFiber;434 oldFiber = null;435 } else {436 nextOldFiber = oldFiber.sibling;437 }438 var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], priority);439 if (newFiber === null) {440 if (oldFiber === null) {441 oldFiber = nextOldFiber;442 }443 break;444 }445 if (shouldTrackSideEffects) {446 if (oldFiber && newFiber.alternate === null) {447 deleteChild(returnFiber, oldFiber);448 }449 }450 lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);451 if (previousNewFiber === null) {452 resultingFirstChild = newFiber;453 } else {454 previousNewFiber.sibling = newFiber;455 }456 previousNewFiber = newFiber;457 oldFiber = nextOldFiber;458 }459 if (newIdx === newChildren.length) {460 deleteRemainingChildren(returnFiber, oldFiber);461 return resultingFirstChild;462 }463 if (oldFiber === null) {464 for (; newIdx < newChildren.length; newIdx++) {465 var _newFiber = createChild(returnFiber, newChildren[newIdx], priority);466 if (!_newFiber) {467 continue;468 }469 lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);470 if (previousNewFiber === null) {471 resultingFirstChild = _newFiber;472 } else {473 previousNewFiber.sibling = _newFiber;474 }475 previousNewFiber = _newFiber;476 }477 return resultingFirstChild;478 }479 var existingChildren = mapRemainingChildren(returnFiber, oldFiber);480 for (; newIdx < newChildren.length; newIdx++) {481 var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], priority);482 if (_newFiber2) {483 if (shouldTrackSideEffects) {484 if (_newFiber2.alternate !== null) {485 existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);486 }487 }488 lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);489 if (previousNewFiber === null) {490 resultingFirstChild = _newFiber2;491 } else {492 previousNewFiber.sibling = _newFiber2;493 }494 previousNewFiber = _newFiber2;495 }496 }497 if (shouldTrackSideEffects) {498 existingChildren.forEach(function (child) {499 return deleteChild(returnFiber, child);500 });501 }502 return resultingFirstChild;503 }504 function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, priority) {505 var iteratorFn = getIteratorFn(newChildrenIterable);506 invariant(typeof iteratorFn === 'function', 'An object is not an iterable. This error is likely caused by a bug in ' + 'React. Please file an issue.');507 if (__DEV__) {508 if (typeof newChildrenIterable.entries === 'function') {509 var possibleMap = newChildrenIterable;510 if (possibleMap.entries === iteratorFn) {511 var mapsAsChildrenAddendum = '';512 var owner = ReactCurrentOwner.owner || returnFiber._debugOwner;513 if (owner && typeof owner.tag === 'number') {514 var mapsAsChildrenOwnerName = getComponentName(owner);515 if (mapsAsChildrenOwnerName) {516 mapsAsChildrenAddendum = '\n\nCheck the render method of `' + mapsAsChildrenOwnerName + '`.';517 }518 }519 warning(didWarnAboutMaps, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.%s', mapsAsChildrenAddendum);520 didWarnAboutMaps = true;521 }522 }523 var _newChildren = iteratorFn.call(newChildrenIterable);524 if (_newChildren) {525 var knownKeys = null;526 var _step = _newChildren.next();527 for (; !_step.done; _step = _newChildren.next()) {528 var child = _step.value;529 knownKeys = warnOnDuplicateKey(child, knownKeys);530 }531 }532 }533 var newChildren = iteratorFn.call(newChildrenIterable);534 invariant(newChildren != null, 'An iterable object provided no iterator.');535 var resultingFirstChild = null;536 var previousNewFiber = null;537 var oldFiber = currentFirstChild;538 var lastPlacedIndex = 0;539 var newIdx = 0;540 var nextOldFiber = null;541 var step = newChildren.next();542 for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {543 if (oldFiber.index > newIdx) {544 nextOldFiber = oldFiber;545 oldFiber = null;546 } else {547 nextOldFiber = oldFiber.sibling;548 }549 var newFiber = updateSlot(returnFiber, oldFiber, step.value, priority);550 if (newFiber === null) {551 if (!oldFiber) {552 oldFiber = nextOldFiber;553 }554 break;555 }556 if (shouldTrackSideEffects) {557 if (oldFiber && newFiber.alternate === null) {558 deleteChild(returnFiber, oldFiber);559 }560 }561 lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);562 if (previousNewFiber === null) {563 resultingFirstChild = newFiber;564 } else {565 previousNewFiber.sibling = newFiber;566 }567 previousNewFiber = newFiber;568 oldFiber = nextOldFiber;569 }570 if (step.done) {571 deleteRemainingChildren(returnFiber, oldFiber);572 return resultingFirstChild;573 }574 if (oldFiber === null) {575 for (; !step.done; newIdx++, step = newChildren.next()) {576 var _newFiber3 = createChild(returnFiber, step.value, priority);577 if (_newFiber3 === null) {578 continue;579 }580 lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);581 if (previousNewFiber === null) {582 resultingFirstChild = _newFiber3;583 } else {584 previousNewFiber.sibling = _newFiber3;585 }586 previousNewFiber = _newFiber3;587 }588 return resultingFirstChild;589 }590 var existingChildren = mapRemainingChildren(returnFiber, oldFiber);591 for (; !step.done; newIdx++, step = newChildren.next()) {592 var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, priority);593 if (_newFiber4 !== null) {594 if (shouldTrackSideEffects) {595 if (_newFiber4.alternate !== null) {596 existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);597 }598 }599 lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);600 if (previousNewFiber === null) {601 resultingFirstChild = _newFiber4;602 } else {603 previousNewFiber.sibling = _newFiber4;604 }605 previousNewFiber = _newFiber4;606 }607 }608 if (shouldTrackSideEffects) {609 existingChildren.forEach(function (child) {610 return deleteChild(returnFiber, child);611 });612 }613 return resultingFirstChild;614 }615 function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, priority) {616 if (currentFirstChild !== null && currentFirstChild.tag === HostText) {617 deleteRemainingChildren(returnFiber, currentFirstChild.sibling);618 var existing = useFiber(currentFirstChild, priority);619 existing.pendingProps = textContent;620 existing.return = returnFiber;621 return existing;622 }623 deleteRemainingChildren(returnFiber, currentFirstChild);624 var created = createFiberFromText(textContent, priority);625 created.return = returnFiber;626 return created;627 }628 function reconcileSingleElement(returnFiber, currentFirstChild, element, priority) {629 var key = element.key;630 var child = currentFirstChild;631 while (child !== null) {632 if (child.key === key) {633 if (child.type === element.type) {634 deleteRemainingChildren(returnFiber, child.sibling);635 var existing = useFiber(child, priority);636 existing.ref = coerceRef(child, element);637 existing.pendingProps = element.props;638 existing.return = returnFiber;639 if (__DEV__) {640 existing._debugSource = element._source;641 existing._debugOwner = element._owner;642 }643 return existing;644 } else {645 deleteRemainingChildren(returnFiber, child);646 break;647 }648 } else {649 deleteChild(returnFiber, child);650 }651 child = child.sibling;652 }653 var created = createFiberFromElement(element, priority);654 created.ref = coerceRef(currentFirstChild, element);655 created.return = returnFiber;656 return created;657 }658 function reconcileSingleCoroutine(returnFiber, currentFirstChild, coroutine, priority) {659 var key = coroutine.key;660 var child = currentFirstChild;661 while (child !== null) {662 if (child.key === key) {663 if (child.tag === CoroutineComponent) {664 deleteRemainingChildren(returnFiber, child.sibling);665 var existing = useFiber(child, priority);666 existing.pendingProps = coroutine;667 existing.return = returnFiber;668 return existing;669 } else {670 deleteRemainingChildren(returnFiber, child);671 break;672 }673 } else {674 deleteChild(returnFiber, child);675 }676 child = child.sibling;677 }678 var created = createFiberFromCoroutine(coroutine, priority);679 created.return = returnFiber;680 return created;681 }682 function reconcileSingleYield(returnFiber, currentFirstChild, yieldNode, priority) {683 var child = currentFirstChild;684 if (child !== null) {685 if (child.tag === YieldComponent) {686 deleteRemainingChildren(returnFiber, child.sibling);687 var existing = useFiber(child, priority);688 existing.type = yieldNode.value;689 existing.return = returnFiber;690 return existing;691 } else {692 deleteRemainingChildren(returnFiber, child);693 }694 }695 var created = createFiberFromYield(yieldNode, priority);696 created.type = yieldNode.value;697 created.return = returnFiber;698 return created;699 }700 function reconcileSinglePortal(returnFiber, currentFirstChild, portal, priority) {701 var key = portal.key;702 var child = currentFirstChild;703 while (child !== null) {704 if (child.key === key) {705 if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {706 deleteRemainingChildren(returnFiber, child.sibling);707 var existing = useFiber(child, priority);708 existing.pendingProps = portal.children || [];709 existing.return = returnFiber;710 return existing;711 } else {712 deleteRemainingChildren(returnFiber, child);713 break;714 }715 } else {716 deleteChild(returnFiber, child);717 }718 child = child.sibling;719 }720 var created = createFiberFromPortal(portal, priority);721 created.return = returnFiber;722 return created;723 }724 function reconcileChildFibers(returnFiber, currentFirstChild, newChild, priority) {725 var disableNewFiberFeatures = ReactFeatureFlags.disableNewFiberFeatures;726 var isObject = typeof newChild === 'object' && newChild !== null;727 if (isObject) {728 if (disableNewFiberFeatures) {729 switch (newChild.$$typeof) {730 case REACT_ELEMENT_TYPE:731 return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, priority));732 case REACT_PORTAL_TYPE:733 return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, priority));734 }735 } else {736 switch (newChild.$$typeof) {737 case REACT_ELEMENT_TYPE:738 return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, priority));739 case REACT_COROUTINE_TYPE:740 return placeSingleChild(reconcileSingleCoroutine(returnFiber, currentFirstChild, newChild, priority));741 case REACT_YIELD_TYPE:742 return placeSingleChild(reconcileSingleYield(returnFiber, currentFirstChild, newChild, priority));743 case REACT_PORTAL_TYPE:744 return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, priority));745 }746 }747 }748 if (disableNewFiberFeatures) {749 switch (returnFiber.tag) {750 case ClassComponent:751 {752 if (__DEV__) {753 var instance = returnFiber.stateNode;754 if (instance.render._isMockFunction && typeof newChild === 'undefined') {755 break;756 }757 }758 var Component = returnFiber.type;759 invariant(newChild === null || newChild === false, '%s.render(): A valid React element (or null) must be returned. ' + 'You may have returned undefined, an array or some other ' + 'invalid object.', Component.displayName || Component.name || 'Component');760 break;761 }762 case FunctionalComponent:763 {764 var _Component = returnFiber.type;765 invariant(newChild === null || newChild === false, '%s(...): A valid React element (or null) must be returned. ' + 'You may have returned undefined, an array or some other ' + 'invalid object.', _Component.displayName || _Component.name || 'Component');766 break;767 }768 }769 }770 if (typeof newChild === 'string' || typeof newChild === 'number') {771 return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, priority));772 }773 if (isArray(newChild)) {774 return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, priority);775 }776 if (getIteratorFn(newChild)) {777 return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, priority);778 }779 if (isObject) {780 throwOnInvalidObjectType(returnFiber, newChild);781 }782 if (!disableNewFiberFeatures && typeof newChild === 'undefined') {783 switch (returnFiber.tag) {784 case ClassComponent:785 {...

Full Screen

Full Screen

72ad6676c5f8c20c2282779de202a472dade38ReactChildFiber.js

Source:72ad6676c5f8c20c2282779de202a472dade38ReactChildFiber.js Github

copy

Full Screen

...165 newFiber.effectTag = Placement;166 return lastPlacedIndex;167 }168 }169 function placeSingleChild(newFiber) {170 if (shouldTrackSideEffects && newFiber.alternate === null) {171 newFiber.effectTag = Placement;172 }173 return newFiber;174 }175 function updateTextNode(returnFiber, current, textContent, priority) {176 if (current === null || current.tag !== HostText) {177 var created = createFiberFromText(textContent, priority);178 created.return = returnFiber;179 return created;180 } else {181 var existing = useFiber(current, priority);182 existing.pendingProps = textContent;183 existing.return = returnFiber;184 return existing;185 }186 }187 function updateElement(returnFiber, current, element, priority) {188 if (current === null || current.type !== element.type) {189 var created = createFiberFromElement(element, priority);190 created.ref = coerceRef(current, element);191 created.return = returnFiber;192 return created;193 } else {194 var existing = useFiber(current, priority);195 existing.ref = coerceRef(current, element);196 existing.pendingProps = element.props;197 existing.return = returnFiber;198 if (__DEV__) {199 existing._debugSource = element._source;200 existing._debugOwner = element._owner;201 }202 return existing;203 }204 }205 function updateCoroutine(returnFiber, current, coroutine, priority) {206 if (current === null || current.tag !== CoroutineComponent) {207 var created = createFiberFromCoroutine(coroutine, priority);208 created.return = returnFiber;209 return created;210 } else {211 var existing = useFiber(current, priority);212 existing.pendingProps = coroutine;213 existing.return = returnFiber;214 return existing;215 }216 }217 function updateYield(returnFiber, current, yieldNode, priority) {218 if (current === null || current.tag !== YieldComponent) {219 var created = createFiberFromYield(yieldNode, priority);220 created.type = yieldNode.value;221 created.return = returnFiber;222 return created;223 } else {224 var existing = useFiber(current, priority);225 existing.type = yieldNode.value;226 existing.return = returnFiber;227 return existing;228 }229 }230 function updatePortal(returnFiber, current, portal, priority) {231 if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {232 var created = createFiberFromPortal(portal, priority);233 created.return = returnFiber;234 return created;235 } else {236 var existing = useFiber(current, priority);237 existing.pendingProps = portal.children || [];238 existing.return = returnFiber;239 return existing;240 }241 }242 function updateFragment(returnFiber, current, fragment, priority) {243 if (current === null || current.tag !== Fragment) {244 var created = createFiberFromFragment(fragment, priority);245 created.return = returnFiber;246 return created;247 } else {248 var existing = useFiber(current, priority);249 existing.pendingProps = fragment;250 existing.return = returnFiber;251 return existing;252 }253 }254 function createChild(returnFiber, newChild, priority) {255 if (typeof newChild === 'string' || typeof newChild === 'number') {256 var created = createFiberFromText('' + newChild, priority);257 created.return = returnFiber;258 return created;259 }260 if (typeof newChild === 'object' && newChild !== null) {261 switch (newChild.$$typeof) {262 case REACT_ELEMENT_TYPE:263 {264 var _created = createFiberFromElement(newChild, priority);265 _created.ref = coerceRef(null, newChild);266 _created.return = returnFiber;267 return _created;268 }269 case REACT_COROUTINE_TYPE:270 {271 var _created2 = createFiberFromCoroutine(newChild, priority);272 _created2.return = returnFiber;273 return _created2;274 }275 case REACT_YIELD_TYPE:276 {277 var _created3 = createFiberFromYield(newChild, priority);278 _created3.type = newChild.value;279 _created3.return = returnFiber;280 return _created3;281 }282 case REACT_PORTAL_TYPE:283 {284 var _created4 = createFiberFromPortal(newChild, priority);285 _created4.return = returnFiber;286 return _created4;287 }288 }289 if (isArray(newChild) || getIteratorFn(newChild)) {290 var _created5 = createFiberFromFragment(newChild, priority);291 _created5.return = returnFiber;292 return _created5;293 }294 throwOnInvalidObjectType(returnFiber, newChild);295 }296 return null;297 }298 function updateSlot(returnFiber, oldFiber, newChild, priority) {299 var key = oldFiber !== null ? oldFiber.key : null;300 if (typeof newChild === 'string' || typeof newChild === 'number') {301 if (key !== null) {302 return null;303 }304 return updateTextNode(returnFiber, oldFiber, '' + newChild, priority);305 }306 if (typeof newChild === 'object' && newChild !== null) {307 switch (newChild.$$typeof) {308 case REACT_ELEMENT_TYPE:309 {310 if (newChild.key === key) {311 return updateElement(returnFiber, oldFiber, newChild, priority);312 } else {313 return null;314 }315 }316 case REACT_COROUTINE_TYPE:317 {318 if (newChild.key === key) {319 return updateCoroutine(returnFiber, oldFiber, newChild, priority);320 } else {321 return null;322 }323 }324 case REACT_YIELD_TYPE:325 {326 if (key === null) {327 return updateYield(returnFiber, oldFiber, newChild, priority);328 } else {329 return null;330 }331 }332 case REACT_PORTAL_TYPE:333 {334 if (newChild.key === key) {335 return updatePortal(returnFiber, oldFiber, newChild, priority);336 } else {337 return null;338 }339 }340 }341 if (isArray(newChild) || getIteratorFn(newChild)) {342 if (key !== null) {343 return null;344 }345 return updateFragment(returnFiber, oldFiber, newChild, priority);346 }347 throwOnInvalidObjectType(returnFiber, newChild);348 }349 return null;350 }351 function updateFromMap(existingChildren, returnFiber, newIdx, newChild, priority) {352 if (typeof newChild === 'string' || typeof newChild === 'number') {353 var matchedFiber = existingChildren.get(newIdx) || null;354 return updateTextNode(returnFiber, matchedFiber, '' + newChild, priority);355 }356 if (typeof newChild === 'object' && newChild !== null) {357 switch (newChild.$$typeof) {358 case REACT_ELEMENT_TYPE:359 {360 var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;361 return updateElement(returnFiber, _matchedFiber, newChild, priority);362 }363 case REACT_COROUTINE_TYPE:364 {365 var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;366 return updateCoroutine(returnFiber, _matchedFiber2, newChild, priority);367 }368 case REACT_YIELD_TYPE:369 {370 var _matchedFiber3 = existingChildren.get(newIdx) || null;371 return updateYield(returnFiber, _matchedFiber3, newChild, priority);372 }373 case REACT_PORTAL_TYPE:374 {375 var _matchedFiber4 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;376 return updatePortal(returnFiber, _matchedFiber4, newChild, priority);377 }378 }379 if (isArray(newChild) || getIteratorFn(newChild)) {380 var _matchedFiber5 = existingChildren.get(newIdx) || null;381 return updateFragment(returnFiber, _matchedFiber5, newChild, priority);382 }383 throwOnInvalidObjectType(returnFiber, newChild);384 }385 return null;386 }387 function warnOnDuplicateKey(child, knownKeys) {388 if (__DEV__) {389 if (typeof child !== 'object' || child === null) {390 return knownKeys;391 }392 switch (child.$$typeof) {393 case REACT_ELEMENT_TYPE:394 case REACT_COROUTINE_TYPE:395 case REACT_PORTAL_TYPE:396 var key = child.key;397 if (typeof key !== 'string') {398 break;399 }400 if (knownKeys === null) {401 knownKeys = new Set();402 knownKeys.add(key);403 break;404 }405 if (!knownKeys.has(key)) {406 knownKeys.add(key);407 break;408 }409 warning(false, 'Encountered two children with the same key, ' + '`%s`. Child keys must be unique; when two children share a key, ' + 'only the first child will be used.%s', key, getCurrentFiberStackAddendum());410 break;411 default:412 break;413 }414 }415 return knownKeys;416 }417 function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, priority) {418 if (__DEV__) {419 var knownKeys = null;420 for (var i = 0; i < newChildren.length; i++) {421 var child = newChildren[i];422 knownKeys = warnOnDuplicateKey(child, knownKeys);423 }424 }425 var resultingFirstChild = null;426 var previousNewFiber = null;427 var oldFiber = currentFirstChild;428 var lastPlacedIndex = 0;429 var newIdx = 0;430 var nextOldFiber = null;431 for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {432 if (oldFiber.index > newIdx) {433 nextOldFiber = oldFiber;434 oldFiber = null;435 } else {436 nextOldFiber = oldFiber.sibling;437 }438 var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], priority);439 if (newFiber === null) {440 if (oldFiber === null) {441 oldFiber = nextOldFiber;442 }443 break;444 }445 if (shouldTrackSideEffects) {446 if (oldFiber && newFiber.alternate === null) {447 deleteChild(returnFiber, oldFiber);448 }449 }450 lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);451 if (previousNewFiber === null) {452 resultingFirstChild = newFiber;453 } else {454 previousNewFiber.sibling = newFiber;455 }456 previousNewFiber = newFiber;457 oldFiber = nextOldFiber;458 }459 if (newIdx === newChildren.length) {460 deleteRemainingChildren(returnFiber, oldFiber);461 return resultingFirstChild;462 }463 if (oldFiber === null) {464 for (; newIdx < newChildren.length; newIdx++) {465 var _newFiber = createChild(returnFiber, newChildren[newIdx], priority);466 if (!_newFiber) {467 continue;468 }469 lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);470 if (previousNewFiber === null) {471 resultingFirstChild = _newFiber;472 } else {473 previousNewFiber.sibling = _newFiber;474 }475 previousNewFiber = _newFiber;476 }477 return resultingFirstChild;478 }479 var existingChildren = mapRemainingChildren(returnFiber, oldFiber);480 for (; newIdx < newChildren.length; newIdx++) {481 var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], priority);482 if (_newFiber2) {483 if (shouldTrackSideEffects) {484 if (_newFiber2.alternate !== null) {485 existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);486 }487 }488 lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);489 if (previousNewFiber === null) {490 resultingFirstChild = _newFiber2;491 } else {492 previousNewFiber.sibling = _newFiber2;493 }494 previousNewFiber = _newFiber2;495 }496 }497 if (shouldTrackSideEffects) {498 existingChildren.forEach(function (child) {499 return deleteChild(returnFiber, child);500 });501 }502 return resultingFirstChild;503 }504 function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, priority) {505 var iteratorFn = getIteratorFn(newChildrenIterable);506 invariant(typeof iteratorFn === 'function', 'An object is not an iterable. This error is likely caused by a bug in ' + 'React. Please file an issue.');507 if (__DEV__) {508 if (typeof newChildrenIterable.entries === 'function') {509 var possibleMap = newChildrenIterable;510 if (possibleMap.entries === iteratorFn) {511 var mapsAsChildrenAddendum = '';512 var owner = ReactCurrentOwner.owner || returnFiber._debugOwner;513 if (owner && typeof owner.tag === 'number') {514 var mapsAsChildrenOwnerName = getComponentName(owner);515 if (mapsAsChildrenOwnerName) {516 mapsAsChildrenAddendum = '\n\nCheck the render method of `' + mapsAsChildrenOwnerName + '`.';517 }518 }519 warning(didWarnAboutMaps, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.%s', mapsAsChildrenAddendum);520 didWarnAboutMaps = true;521 }522 }523 var _newChildren = iteratorFn.call(newChildrenIterable);524 if (_newChildren) {525 var knownKeys = null;526 var _step = _newChildren.next();527 for (; !_step.done; _step = _newChildren.next()) {528 var child = _step.value;529 knownKeys = warnOnDuplicateKey(child, knownKeys);530 }531 }532 }533 var newChildren = iteratorFn.call(newChildrenIterable);534 invariant(newChildren != null, 'An iterable object provided no iterator.');535 var resultingFirstChild = null;536 var previousNewFiber = null;537 var oldFiber = currentFirstChild;538 var lastPlacedIndex = 0;539 var newIdx = 0;540 var nextOldFiber = null;541 var step = newChildren.next();542 for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {543 if (oldFiber.index > newIdx) {544 nextOldFiber = oldFiber;545 oldFiber = null;546 } else {547 nextOldFiber = oldFiber.sibling;548 }549 var newFiber = updateSlot(returnFiber, oldFiber, step.value, priority);550 if (newFiber === null) {551 if (!oldFiber) {552 oldFiber = nextOldFiber;553 }554 break;555 }556 if (shouldTrackSideEffects) {557 if (oldFiber && newFiber.alternate === null) {558 deleteChild(returnFiber, oldFiber);559 }560 }561 lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);562 if (previousNewFiber === null) {563 resultingFirstChild = newFiber;564 } else {565 previousNewFiber.sibling = newFiber;566 }567 previousNewFiber = newFiber;568 oldFiber = nextOldFiber;569 }570 if (step.done) {571 deleteRemainingChildren(returnFiber, oldFiber);572 return resultingFirstChild;573 }574 if (oldFiber === null) {575 for (; !step.done; newIdx++, step = newChildren.next()) {576 var _newFiber3 = createChild(returnFiber, step.value, priority);577 if (_newFiber3 === null) {578 continue;579 }580 lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);581 if (previousNewFiber === null) {582 resultingFirstChild = _newFiber3;583 } else {584 previousNewFiber.sibling = _newFiber3;585 }586 previousNewFiber = _newFiber3;587 }588 return resultingFirstChild;589 }590 var existingChildren = mapRemainingChildren(returnFiber, oldFiber);591 for (; !step.done; newIdx++, step = newChildren.next()) {592 var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, priority);593 if (_newFiber4 !== null) {594 if (shouldTrackSideEffects) {595 if (_newFiber4.alternate !== null) {596 existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);597 }598 }599 lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);600 if (previousNewFiber === null) {601 resultingFirstChild = _newFiber4;602 } else {603 previousNewFiber.sibling = _newFiber4;604 }605 previousNewFiber = _newFiber4;606 }607 }608 if (shouldTrackSideEffects) {609 existingChildren.forEach(function (child) {610 return deleteChild(returnFiber, child);611 });612 }613 return resultingFirstChild;614 }615 function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, priority) {616 if (currentFirstChild !== null && currentFirstChild.tag === HostText) {617 deleteRemainingChildren(returnFiber, currentFirstChild.sibling);618 var existing = useFiber(currentFirstChild, priority);619 existing.pendingProps = textContent;620 existing.return = returnFiber;621 return existing;622 }623 deleteRemainingChildren(returnFiber, currentFirstChild);624 var created = createFiberFromText(textContent, priority);625 created.return = returnFiber;626 return created;627 }628 function reconcileSingleElement(returnFiber, currentFirstChild, element, priority) {629 var key = element.key;630 var child = currentFirstChild;631 while (child !== null) {632 if (child.key === key) {633 if (child.type === element.type) {634 deleteRemainingChildren(returnFiber, child.sibling);635 var existing = useFiber(child, priority);636 existing.ref = coerceRef(child, element);637 existing.pendingProps = element.props;638 existing.return = returnFiber;639 if (__DEV__) {640 existing._debugSource = element._source;641 existing._debugOwner = element._owner;642 }643 return existing;644 } else {645 deleteRemainingChildren(returnFiber, child);646 break;647 }648 } else {649 deleteChild(returnFiber, child);650 }651 child = child.sibling;652 }653 var created = createFiberFromElement(element, priority);654 created.ref = coerceRef(currentFirstChild, element);655 created.return = returnFiber;656 return created;657 }658 function reconcileSingleCoroutine(returnFiber, currentFirstChild, coroutine, priority) {659 var key = coroutine.key;660 var child = currentFirstChild;661 while (child !== null) {662 if (child.key === key) {663 if (child.tag === CoroutineComponent) {664 deleteRemainingChildren(returnFiber, child.sibling);665 var existing = useFiber(child, priority);666 existing.pendingProps = coroutine;667 existing.return = returnFiber;668 return existing;669 } else {670 deleteRemainingChildren(returnFiber, child);671 break;672 }673 } else {674 deleteChild(returnFiber, child);675 }676 child = child.sibling;677 }678 var created = createFiberFromCoroutine(coroutine, priority);679 created.return = returnFiber;680 return created;681 }682 function reconcileSingleYield(returnFiber, currentFirstChild, yieldNode, priority) {683 var child = currentFirstChild;684 if (child !== null) {685 if (child.tag === YieldComponent) {686 deleteRemainingChildren(returnFiber, child.sibling);687 var existing = useFiber(child, priority);688 existing.type = yieldNode.value;689 existing.return = returnFiber;690 return existing;691 } else {692 deleteRemainingChildren(returnFiber, child);693 }694 }695 var created = createFiberFromYield(yieldNode, priority);696 created.type = yieldNode.value;697 created.return = returnFiber;698 return created;699 }700 function reconcileSinglePortal(returnFiber, currentFirstChild, portal, priority) {701 var key = portal.key;702 var child = currentFirstChild;703 while (child !== null) {704 if (child.key === key) {705 if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {706 deleteRemainingChildren(returnFiber, child.sibling);707 var existing = useFiber(child, priority);708 existing.pendingProps = portal.children || [];709 existing.return = returnFiber;710 return existing;711 } else {712 deleteRemainingChildren(returnFiber, child);713 break;714 }715 } else {716 deleteChild(returnFiber, child);717 }718 child = child.sibling;719 }720 var created = createFiberFromPortal(portal, priority);721 created.return = returnFiber;722 return created;723 }724 function reconcileChildFibers(returnFiber, currentFirstChild, newChild, priority) {725 var disableNewFiberFeatures = ReactFeatureFlags.disableNewFiberFeatures;726 var isObject = typeof newChild === 'object' && newChild !== null;727 if (isObject) {728 if (disableNewFiberFeatures) {729 switch (newChild.$$typeof) {730 case REACT_ELEMENT_TYPE:731 return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, priority));732 case REACT_PORTAL_TYPE:733 return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, priority));734 }735 } else {736 switch (newChild.$$typeof) {737 case REACT_ELEMENT_TYPE:738 return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, priority));739 case REACT_COROUTINE_TYPE:740 return placeSingleChild(reconcileSingleCoroutine(returnFiber, currentFirstChild, newChild, priority));741 case REACT_YIELD_TYPE:742 return placeSingleChild(reconcileSingleYield(returnFiber, currentFirstChild, newChild, priority));743 case REACT_PORTAL_TYPE:744 return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, priority));745 }746 }747 }748 if (disableNewFiberFeatures) {749 switch (returnFiber.tag) {750 case ClassComponent:751 {752 if (__DEV__) {753 var instance = returnFiber.stateNode;754 if (instance.render._isMockFunction && typeof newChild === 'undefined') {755 break;756 }757 }758 var Component = returnFiber.type;759 invariant(newChild === null || newChild === false, '%s.render(): A valid React element (or null) must be returned. ' + 'You may have returned undefined, an array or some other ' + 'invalid object.', Component.displayName || Component.name || 'Component');760 break;761 }762 case FunctionalComponent:763 {764 var _Component = returnFiber.type;765 invariant(newChild === null || newChild === false, '%s(...): A valid React element (or null) must be returned. ' + 'You may have returned undefined, an array or some other ' + 'invalid object.', _Component.displayName || _Component.name || 'Component');766 break;767 }768 }769 }770 if (typeof newChild === 'string' || typeof newChild === 'number') {771 return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, priority));772 }773 if (isArray(newChild)) {774 return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, priority);775 }776 if (getIteratorFn(newChild)) {777 return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, priority);778 }779 if (isObject) {780 throwOnInvalidObjectType(returnFiber, newChild);781 }782 if (!disableNewFiberFeatures && typeof newChild === 'undefined') {783 switch (returnFiber.tag) {784 case ClassComponent:785 {...

Full Screen

Full Screen

react-diff.js

Source:react-diff.js Github

copy

Full Screen

...271 existingChildren.forEach((child) => deleteChild(returnFiber, child));272 }273 return resultingFirstChild; // 链表头节点274}275function placeSingleChild(fiber) {276 if (shouldTrackSideEffects && newFiber.alternate === null) {277 fiber.flags = Placement;278 }279 return fiber;280}281function reconcileChildFibers(returnFiber, currentFirstChild, newChild) {282 if (newChild.type === REACT_FRAGMENT_TYPE) {283 newChild = newChild.props.children;284 }285 const isObject = typeof newChild === 'object' && newChild !== null;286 if (isObject) {287 switch (newChild.$$typeof) {288 case REACT_ELEMENT_TYPE: // react节点 打上flags属性289 return placeSingleChild(290 reconcileSingleElement(returnFiber, currentFirstChild, newChild)291 );292 }293 }294 // 新节点为普通的文本类型295 if (typeof newChild === 'string' || typeof newChild === 'number') {296 return placeSingleChild(297 reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild)298 );299 }300 // 新节点是数组301 if (Array.isArray(newChild)) {302 return reconcileChildrenArray(returnFiber, currentFirstChild, newChild);303 }...

Full Screen

Full Screen

ReactChildFiber.js

Source:ReactChildFiber.js Github

copy

Full Screen

...45 created.return = returnFiber;46 return created;47 }48 // 标志当前fiber需要在commit阶段插入DOM49 function placeSingleChild(fiber) {50 // shouldTrackSideEffects 为true表示 更新51 // alternate 不存在,表示新增的节点52 // alternate 存在,表示需要更新的节点53 if (shouldTrackSideEffects && !fiber.alternate) {54 // 为fiber节点打上 更新 effect标记55 fiber.effectTag = Placement;56 }57 return fiber;58 }59 function reconcileChildrenArray(returnFiber, currentFirstChild, newChild) {60 // TODO array diff61 let prev;62 let first;63 for (let i = 0; i < newChild.length; i++) {64 const child = newChild[i];65 // 创建子节点的fiber节点66 const newFiber = createChild(returnFiber, child);67 if (!newFiber) {68 continue;69 }70 // 为新的fiber节点打上 effect标记71 placeSingleChild(newFiber);72 if (prev) {73 prev.sibling = newFiber;74 }75 if (!first) {76 first = newFiber;77 }78 prev = newFiber;79 }80 return first;81 }82 function reconcileChildFibers(returnFiber, currentFirstChild, newChild) {83 // React.createElement类型 或者 子节点是String、Number对应的Array类型84 const isObject = typeof newChild === 'object' && newChild !== null;85 if (isObject) {86 // 根据 react 不同元素类型,执行不同逻辑87 switch (newChild.$$typeof) {88 case REACT_ELEMENT_TYPE:89 // 当前节点为元素节点90 return placeSingleChild(reconcileSingleElement(91 returnFiber,92 currentFirstChild,93 newChild94 ))95 }96 // 在 beginWork update各类Component时并未处理HostText,这里处理单个HostText97 if (typeof newChild === 'number' || typeof newChild === 'string') {98 return placeSingleChild(reconcileSingleTextNode(99 returnFiber,100 currentFirstChild,101 newChild102 ))103 }104 // 在 beginWork update各类Component时并未处理HostText,这里处理多个HostText105 if (Array.isArray(newChild)) {106 // 当有多个子节点时107 return reconcileChildrenArray(108 returnFiber,109 currentFirstChild,110 newChild111 )112 }...

Full Screen

Full Screen

ReactChildFiber.dev.js

Source:ReactChildFiber.dev.js Github

copy

Full Screen

...12 var created = (0, _ReactFiber.createFiberFromElement)(element); //div#title13 created["return"] = returnFiber;14 return created;15 }16 function placeSingleChild(newFiber) {17 //如果当前需要跟踪父作用,并且当前这个新的fiber它的替身不存在18 if (shouldTrackSideEffects && !newFiber.alternate) {19 //给这个新fiber添加一个副作用,表示在未来提前阶段的DOM操作中会向真实DOM树中添加此节点20 newFiber.flags = _ReactFiberFlags.Placement;21 }22 return newFiber;23 }24 /**25 * 26 * @param {*} returnFiber 新的父fiber27 * @param {*} currentFirstChild current就是老的意思,老的第一个子fiber28 * @param {*} newChild 新的虚拟DOM29 */30 function reconcileChildFibers(returnFiber, currentFirstChild, newChild) {31 //判断newChild是不是一个对象,如果是的话说明新的虚拟DOM只有一个React元素节点32 var isObject = _typeof(newChild) === 'object' && newChild; //说明新的虚拟DOM是单节点33 if (isObject) {34 switch (newChild.$$typeof) {35 case _ReactSymbols.REACT_ELEMENT_TYPE:36 return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild));37 }38 }39 }40 return reconcileChildFibers;41}42var reconcileChildFibers = childReconciler(true);43exports.reconcileChildFibers = reconcileChildFibers;44var mountChildFibers = childReconciler(false);...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const context = await browser.newContext();5 const page = await context.newPage();6 await browser.close();7})();8Recommended Posts: Playwright | placeSingleChild()

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium, webkit, firefox } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const context = await browser.newContext();5 const page = await context.newPage();6 await page.placeSingleChild();7 await browser.close();8})();9const { chromium, webkit, firefox } = require('playwright');10(async () => {11 const browser = await chromium.launch();12 const context = await browser.newContext();13 const page = await context.newPage();14 await page.placeSingleChild();15 await browser.close();16})();17const { chromium, webkit, firefox } = require('playwright');18(async () => {19 const browser = await chromium.launch();20 const context = await browser.newContext();21 const page = await context.newPage();22 await page.placeSingleChild();23 await browser.close();24})();25const { chromium, webkit, firefox } = require('playwright');26(async () => {27 const browser = await chromium.launch();28 const context = await browser.newContext();29 const page = await context.newPage();30 await page.placeSingleChild();31 await browser.close();32})();33const { chromium, webkit, firefox } = require('playwright');34(async () => {35 const browser = await chromium.launch();36 const context = await browser.newContext();37 const page = await context.newPage();38 await page.placeSingleChild();39 await browser.close();40})();41const { chromium, webkit, firefox } = require('playwright');42(async () => {43 const browser = await chromium.launch();44 const context = await browser.newContext();45 const page = await context.newPage();46 await page.placeSingleChild();47 await browser.close();48})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const {chromium} = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const page = await browser.newPage();5 await page.placeSingleChild('input[name="q"]', 'Playwright');6 await page.click('input[name="q"]');7 await page.waitForSelector('text=Playwright');8 await browser.close();9})();10const {chromium} = require('playwright');11(async () => {12 const browser = await chromium.launch();13 const page = await browser.newPage();14 await page.placeSingleChild('input[name="q"]', 'Playwright');15 await page.click('input[name="q"]');16 await page.waitForSelector('text=Playwright');17 await browser.close();18})();19const {chromium} = require('playwright');20(async () => {21 const browser = await chromium.launch();22 const page = await browser.newPage();23 await page.placeSingleChild('input[name="q"]', 'Playwright');24 await page.click('input[name="q"]');25 await page.waitForSelector('text=Playwright');26 await browser.close();27})();28const {chromium} = require('playwright');29(async () => {30 const browser = await chromium.launch();31 const page = await browser.newPage();32 await page.placeSingleChild('input[name="q"]', 'Playwright');33 await page.click('input[name="q"]');34 await page.waitForSelector('text=Playwright');35 await browser.close();36})();37const {chromium} = require('playwright');38(async () => {39 const browser = await chromium.launch();40 const page = await browser.newPage();41 await page.placeSingleChild('input[name="q"]', 'Playwright');42 await page.click('input[name="q

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2const { placeSingleChild } = require('playwright/lib/server/supplements/recorder/recorderSupplement');3(async () => {4 const browser = await chromium.launch({ headless: false });5 const context = await browser.newContext();6 const page = await context.newPage();7 await page.waitForSelector('text=Sign In');8 await placeSingleChild(page, 'text=Sign In');9 await page.click('text=Sign In');10 await page.waitForSelector('input[name="userLoginId"]');11 await page.click('input[name="userLoginId"]');12 await page.fill('input[name="userLoginId"]', 'your email id');13 await page.click('input[name="password"]');14 await page.fill('input[name="password"]', 'your password');15 await page.click('button[type="submit"]');16 await page.waitForSelector('text=Continue Watching for Anu');17 await page.click('text=Continue Watching for Anu');18 await page.waitForSelector('text=Episode 1');19 await page.click('text=Episode 1');20 await page.waitForSelector('text=Episode 2');21 await page.click('text=Episode 2');22 await page.waitForSelector('text=Episode 3');23 await page.click('text=Episode 3');24 await page.waitForSelector('text=Episode 4');25 await page.click('text=Episode 4');26 await page.waitForSelector('text=Episode 5');27 await page.click('text=Episode 5');28 await page.waitForSelector('text=Episode 6');29 await page.click('text=Episode 6');30 await page.waitForSelector('text=Episode 7');31 await page.click('text=Episode 7');32 await page.waitForSelector('text=Episode 8');33 await page.click('text=Episode 8');34 await page.waitForSelector('text=Episode 9');35 await page.click('text=Episode 9');36 await page.waitForSelector('text=Episode 10');37 await page.click('text=Episode 10');38 await page.waitForSelector('text=Episode 11');39 await page.click('text=Episode 11');40 await page.waitForSelector('text=Episode 12');41 await page.click('text=Episode 12');

Full Screen

Using AI Code Generation

copy

Full Screen

1const { _electron: electron } = require('playwright');2await electron.placeSingleChild(0, 0, 0, 0);3const { _electron: electron } = require('playwright');4await electron.placeSingleChild(0, 0, 0, 0);5const { _electron: electron } = require('playwright');6await electron.placeSingleChild(0, 0, 0, 0);7const { _electron: electron } = require('playwright');8await electron.placeSingleChild(0, 0, 0, 0);9const { _electron: electron } = require('playwright');10await electron.placeSingleChild(0, 0, 0, 0);11const { _electron: electron } = require('playwright');12await electron.placeSingleChild(0, 0, 0, 0);13const { _electron: electron } = require('playwright');14await electron.placeSingleChild(0, 0, 0, 0);15const { _electron: electron } = require('playwright');16await electron.placeSingleChild(0, 0, 0, 0);17const { _electron: electron } = require('playwright');18await electron.placeSingleChild(0, 0, 0, 0);19const { _electron: electron } = require('playwright');20await electron.placeSingleChild(0, 0, 0, 0);

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2const { placeSingleChild } = require('playwright/lib/server/browserContext');3(async () => {4 const browser = await chromium.launch();5 const page = await placeSingleChild(browser._defaultContext, 'page', {});6 await page.screenshot({ path: 'google.png' });7 await browser.close();8})();

Full Screen

Using AI Code Generation

copy

Full Screen

1import { placeSingleChild } from 'playwright/lib/server/dom.js';2const element = document.getElementById('id');3const child = document.createElement('div');4placeSingleChild(element, child);5await page.waitForSelector('#id > div');6import { placeSingleChild } from 'playwright/lib/server/dom.js';7const element = document.getElementById('id');8const child = document.createElement('div');9placeSingleChild(element, child);10await page.waitForSelector('#id > div');11import { placeSingleChild } from 'playwright/lib/server/dom.js';12const element = document.getElementById('id');13const child = document.createElement('div');14placeSingleChild(element, child);15await page.waitForSelector('#id > div');16import { placeSingleChild } from 'playwright/lib/server/dom.js';17const element = document.getElementById('id');18const child = document.createElement('div');19placeSingleChild(element, child);20await page.waitForSelector('#id > div');21import { placeSingleChild } from 'playwright/lib/server/dom.js';22const element = document.getElementById('id');23const child = document.createElement('div');24placeSingleChild(element, child);25await page.waitForSelector('#id > div');26import { placeSingleChild } from 'playwright/lib/server/dom.js';27const element = document.getElementById('id');28const child = document.createElement('div');29placeSingleChild(element, child);30await page.waitForSelector('#id > div');31import { placeSingleChild } from 'playwright/lib/server/dom.js';32const element = document.getElementById('id');33const child = document.createElement('div');34placeSingleChild(element, child);35await page.waitForSelector('#id > div');36import { placeSingleChild } from 'playwright/lib/server/dom.js';37const element = document.getElementById('id');38const child = document.createElement('div');39placeSingleChild(element,

Full Screen

Using AI Code Generation

copy

Full Screen

1const child = page.locator('.child');2const parent = page.locator('.parent');3await child.placeSingleChild(parent, 'center', 'center');4const child = page.locator('.child');5const parent = page.locator('.parent');6await child.placeSingleChild(parent, 'left', 'top');7const child = page.locator('.child');8const parent = page.locator('.parent');9await child.placeSingleChild(parent, 'right', 'bottom');10const child = page.locator('.child');11const parent = page.locator('.parent');12await child.placeSingleChild(parent, 'right', 'top');13const child = page.locator('.child');14const parent = page.locator('.parent');15await child.placeSingleChild(parent, 'left', 'bottom');16const child = page.locator('.child');17const parent = page.locator('.parent');18await child.placeSingleChild(parent, 'center', 'center', 10);19const child = page.locator('.child');20const parent = page.locator('.parent');21await child.placeSingleChild(parent, 'left', 'top', 10);22const child = page.locator('.child');23const parent = page.locator('.parent');24await child.placeSingleChild(parent, 'right', 'bottom', 10);25const child = page.locator('.child');26const parent = page.locator('.parent');27await child.placeSingleChild(parent, 'right', 'top', 10);28const child = page.locator('.child');29const parent = page.locator('.parent');30await child.placeSingleChild(parent, 'left', 'bottom', 10);

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const page = await browser.newPage();5 await page.waitForSelector('#iframeResult');6 const frame = await page.frame({ name: 'iframeResult' });7 await frame.waitForSelector('button');8 const [popup] = await Promise.all([9 new Promise(resolve => browser.once('popup', resolve)),10 frame.click('button'),11 ]);12 await popup.waitForSelector('#myAnchor');13 const [popup2] = await Promise.all([14 new Promise(resolve => browser.once('popup', resolve)),15 popup.click('#myAnchor'),16 ]);17 await popup2.waitForSelector('#myP');18 await popup2.click('#myP');19 await page.bringToFront();20 const childWindow = await browser.childWindows();21 const childWindow1 = childWindow[0];22 const childWindow2 = childWindow[1];23 await childWindow1.placeSingleChild(childWindow2, { x: 0, y: 0 }, { x: 0, y: 0 });24 await browser.close();25})();

Full Screen

Playwright tutorial

LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.

Chapters:

  1. What is Playwright : Playwright is comparatively new but has gained good popularity. Get to know some history of the Playwright with some interesting facts connected with it.
  2. How To Install Playwright : Learn in detail about what basic configuration and dependencies are required for installing Playwright and run a test. Get a step-by-step direction for installing the Playwright automation framework.
  3. Playwright Futuristic Features: Launched in 2020, Playwright gained huge popularity quickly because of some obliging features such as Playwright Test Generator and Inspector, Playwright Reporter, Playwright auto-waiting mechanism and etc. Read up on those features to master Playwright testing.
  4. What is Component Testing: Component testing in Playwright is a unique feature that allows a tester to test a single component of a web application without integrating them with other elements. Learn how to perform Component testing on the Playwright automation framework.
  5. Inputs And Buttons In Playwright: Every website has Input boxes and buttons; learn about testing inputs and buttons with different scenarios and examples.
  6. Functions and Selectors in Playwright: Learn how to launch the Chromium browser with Playwright. Also, gain a better understanding of some important functions like “BrowserContext,” which allows you to run multiple browser sessions, and “newPage” which interacts with a page.
  7. Handling Alerts and Dropdowns in Playwright : Playwright interact with different types of alerts and pop-ups, such as simple, confirmation, and prompt, and different types of dropdowns, such as single selector and multi-selector get your hands-on with handling alerts and dropdown in Playright testing.
  8. Playwright vs Puppeteer: Get to know about the difference between two testing frameworks and how they are different than one another, which browsers they support, and what features they provide.
  9. Run Playwright Tests on LambdaTest: Playwright testing with LambdaTest leverages test performance to the utmost. You can run multiple Playwright tests in Parallel with the LammbdaTest test cloud. Get a step-by-step guide to run your Playwright test on the LambdaTest platform.
  10. Playwright Python Tutorial: Playwright automation framework support all major languages such as Python, JavaScript, TypeScript, .NET and etc. However, there are various advantages to Python end-to-end testing with Playwright because of its versatile utility. Get the hang of Playwright python testing with this chapter.
  11. Playwright End To End Testing Tutorial: Get your hands on with Playwright end-to-end testing and learn to use some exciting features such as TraceViewer, Debugging, Networking, Component testing, Visual testing, and many more.
  12. Playwright Video Tutorial: Watch the video tutorials on Playwright testing from experts and get a consecutive in-depth explanation of Playwright automation testing.

Run Playwright Internal automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful