How to use makeInsertMarkup method in Playwright Internal

Best JavaScript code snippet using playwright-internal

c576cd6bed54e7fc21552dda7dfd4684887f04ReactMultiChild.js

Source:c576cd6bed54e7fc21552dda7dfd4684887f04ReactMultiChild.js Github

copy

Full Screen

...7var ReactChildReconciler = require('ReactChildReconciler');8var emptyFunction = require('fbjs/lib/emptyFunction');9var flattenChildren = require('flattenChildren');10var invariant = require('fbjs/lib/invariant');11function makeInsertMarkup(markup, afterNode, toIndex) {12 return {13 type: 'INSERT_MARKUP',14 content: markup,15 fromIndex: null,16 fromNode: null,17 toIndex: toIndex,18 afterNode: afterNode19 };20}21function makeMove(child, afterNode, toIndex) {22 return {23 type: 'MOVE_EXISTING',24 content: null,25 fromIndex: child._mountIndex,26 fromNode: ReactReconciler.getHostNode(child),27 toIndex: toIndex,28 afterNode: afterNode29 };30}31function makeRemove(child, node) {32 return {33 type: 'REMOVE_NODE',34 content: null,35 fromIndex: child._mountIndex,36 fromNode: node,37 toIndex: null,38 afterNode: null39 };40}41function makeSetMarkup(markup) {42 return {43 type: 'SET_MARKUP',44 content: markup,45 fromIndex: null,46 fromNode: null,47 toIndex: null,48 afterNode: null49 };50}51function makeTextContent(textContent) {52 return {53 type: 'TEXT_CONTENT',54 content: textContent,55 fromIndex: null,56 fromNode: null,57 toIndex: null,58 afterNode: null59 };60}61function enqueue(queue, update) {62 if (update) {63 queue = queue || [];64 queue.push(update);65 }66 return queue;67}68function processQueue(inst, updateQueue) {69 ReactComponentEnvironment.processChildrenUpdates(inst, updateQueue);70}71var setChildrenForInstrumentation = emptyFunction;72if (__DEV__) {73 var getDebugID = function getDebugID(inst) {74 if (!inst._debugID) {75 var internal;76 if (internal = ReactInstanceMap.get(inst)) {77 inst = internal;78 }79 }80 return inst._debugID;81 };82 setChildrenForInstrumentation = function setChildrenForInstrumentation(children) {83 var debugID = getDebugID(this);84 if (debugID !== 0) {85 ReactInstrumentation.debugTool.onSetChildren(debugID, children ? Object.keys(children).map(function (key) {86 return children[key]._debugID;87 }) : []);88 }89 };90}91var ReactMultiChild = {92 _reconcilerInstantiateChildren: function _reconcilerInstantiateChildren(nestedChildren, transaction, context) {93 if (__DEV__) {94 var selfDebugID = getDebugID(this);95 if (this._currentElement) {96 try {97 ReactCurrentOwner.current = this._currentElement._owner;98 return ReactChildReconciler.instantiateChildren(nestedChildren, transaction, context, selfDebugID);99 } finally {100 ReactCurrentOwner.current = null;101 }102 }103 }104 return ReactChildReconciler.instantiateChildren(nestedChildren, transaction, context);105 },106 _reconcilerUpdateChildren: function _reconcilerUpdateChildren(prevChildren, nextNestedChildrenElements, mountImages, removedNodes, transaction, context) {107 var nextChildren;108 var selfDebugID = 0;109 if (__DEV__) {110 selfDebugID = getDebugID(this);111 if (this._currentElement) {112 try {113 ReactCurrentOwner.current = this._currentElement._owner;114 nextChildren = flattenChildren(nextNestedChildrenElements, selfDebugID);115 } finally {116 ReactCurrentOwner.current = null;117 }118 ReactChildReconciler.updateChildren(prevChildren, nextChildren, mountImages, removedNodes, transaction, this, this._hostContainerInfo, context, selfDebugID);119 return nextChildren;120 }121 }122 nextChildren = flattenChildren(nextNestedChildrenElements, selfDebugID);123 ReactChildReconciler.updateChildren(prevChildren, nextChildren, mountImages, removedNodes, transaction, this, this._hostContainerInfo, context, selfDebugID);124 return nextChildren;125 },126 mountChildren: function mountChildren(nestedChildren, transaction, context) {127 var children = this._reconcilerInstantiateChildren(nestedChildren, transaction, context);128 this._renderedChildren = children;129 var mountImages = [];130 var index = 0;131 for (var name in children) {132 if (children.hasOwnProperty(name)) {133 var child = children[name];134 var selfDebugID = 0;135 if (__DEV__) {136 selfDebugID = getDebugID(this);137 }138 var mountImage = ReactReconciler.mountComponent(child, transaction, this, this._hostContainerInfo, context, selfDebugID);139 child._mountIndex = index++;140 mountImages.push(mountImage);141 }142 }143 if (__DEV__) {144 setChildrenForInstrumentation.call(this, children);145 }146 return mountImages;147 },148 updateTextContent: function updateTextContent(nextContent) {149 var prevChildren = this._renderedChildren;150 ReactChildReconciler.unmountChildren(prevChildren, false, false);151 for (var name in prevChildren) {152 if (prevChildren.hasOwnProperty(name)) {153 invariant(false, 'updateTextContent called on non-empty component.');154 }155 }156 var updates = [makeTextContent(nextContent)];157 processQueue(this, updates);158 },159 updateMarkup: function updateMarkup(nextMarkup) {160 var prevChildren = this._renderedChildren;161 ReactChildReconciler.unmountChildren(prevChildren, false, false);162 for (var name in prevChildren) {163 if (prevChildren.hasOwnProperty(name)) {164 invariant(false, 'updateTextContent called on non-empty component.');165 }166 }167 var updates = [makeSetMarkup(nextMarkup)];168 processQueue(this, updates);169 },170 updateChildren: function updateChildren(nextNestedChildrenElements, transaction, context) {171 this._updateChildren(nextNestedChildrenElements, transaction, context);172 },173 _updateChildren: function _updateChildren(nextNestedChildrenElements, transaction, context) {174 var prevChildren = this._renderedChildren;175 var removedNodes = {};176 var mountImages = [];177 var nextChildren = this._reconcilerUpdateChildren(prevChildren, nextNestedChildrenElements, mountImages, removedNodes, transaction, context);178 if (!nextChildren && !prevChildren) {179 return;180 }181 var updates = null;182 var name;183 var nextIndex = 0;184 var lastIndex = 0;185 var nextMountIndex = 0;186 var lastPlacedNode = null;187 for (name in nextChildren) {188 if (!nextChildren.hasOwnProperty(name)) {189 continue;190 }191 var prevChild = prevChildren && prevChildren[name];192 var nextChild = nextChildren[name];193 if (prevChild === nextChild) {194 updates = enqueue(updates, this.moveChild(prevChild, lastPlacedNode, nextIndex, lastIndex));195 lastIndex = Math.max(prevChild._mountIndex, lastIndex);196 prevChild._mountIndex = nextIndex;197 } else {198 if (prevChild) {199 lastIndex = Math.max(prevChild._mountIndex, lastIndex);200 }201 updates = enqueue(updates, this._mountChildAtIndex(nextChild, mountImages[nextMountIndex], lastPlacedNode, nextIndex, transaction, context));202 nextMountIndex++;203 }204 nextIndex++;205 lastPlacedNode = ReactReconciler.getHostNode(nextChild);206 }207 for (name in removedNodes) {208 if (removedNodes.hasOwnProperty(name)) {209 updates = enqueue(updates, this._unmountChild(prevChildren[name], removedNodes[name]));210 }211 }212 if (updates) {213 processQueue(this, updates);214 }215 this._renderedChildren = nextChildren;216 if (__DEV__) {217 setChildrenForInstrumentation.call(this, nextChildren);218 }219 },220 unmountChildren: function unmountChildren(safely, skipLifecycle) {221 var renderedChildren = this._renderedChildren;222 ReactChildReconciler.unmountChildren(renderedChildren, safely, skipLifecycle);223 this._renderedChildren = null;224 },225 moveChild: function moveChild(child, afterNode, toIndex, lastIndex) {226 if (child._mountIndex < lastIndex) {227 return makeMove(child, afterNode, toIndex);228 }229 },230 createChild: function createChild(child, afterNode, mountImage) {231 return makeInsertMarkup(mountImage, afterNode, child._mountIndex);232 },233 removeChild: function removeChild(child, node) {234 return makeRemove(child, node);235 },236 _mountChildAtIndex: function _mountChildAtIndex(child, mountImage, afterNode, index, transaction, context) {237 child._mountIndex = index;238 return this.createChild(child, afterNode, mountImage);239 },240 _unmountChild: function _unmountChild(child, node) {241 var update = this.removeChild(child, node);242 child._mountIndex = null;243 return update;244 }245};...

Full Screen

Full Screen

1b89a9ReactMultiChild.js

Source:1b89a9ReactMultiChild.js Github

copy

Full Screen

...7var ReactChildReconciler = require('ReactChildReconciler');8var emptyFunction = require('fbjs/lib/emptyFunction');9var flattenChildren = require('flattenChildren');10var invariant = require('fbjs/lib/invariant');11function makeInsertMarkup(markup, afterNode, toIndex) {12 return {13 type: 'INSERT_MARKUP',14 content: markup,15 fromIndex: null,16 fromNode: null,17 toIndex: toIndex,18 afterNode: afterNode19 };20}21function makeMove(child, afterNode, toIndex) {22 return {23 type: 'MOVE_EXISTING',24 content: null,25 fromIndex: child._mountIndex,26 fromNode: ReactReconciler.getHostNode(child),27 toIndex: toIndex,28 afterNode: afterNode29 };30}31function makeRemove(child, node) {32 return {33 type: 'REMOVE_NODE',34 content: null,35 fromIndex: child._mountIndex,36 fromNode: node,37 toIndex: null,38 afterNode: null39 };40}41function makeSetMarkup(markup) {42 return {43 type: 'SET_MARKUP',44 content: markup,45 fromIndex: null,46 fromNode: null,47 toIndex: null,48 afterNode: null49 };50}51function makeTextContent(textContent) {52 return {53 type: 'TEXT_CONTENT',54 content: textContent,55 fromIndex: null,56 fromNode: null,57 toIndex: null,58 afterNode: null59 };60}61function enqueue(queue, update) {62 if (update) {63 queue = queue || [];64 queue.push(update);65 }66 return queue;67}68function processQueue(inst, updateQueue) {69 ReactComponentEnvironment.processChildrenUpdates(inst, updateQueue);70}71var setChildrenForInstrumentation = emptyFunction;72if (__DEV__) {73 var getDebugID = function getDebugID(inst) {74 if (!inst._debugID) {75 var internal;76 if (internal = ReactInstanceMap.get(inst)) {77 inst = internal;78 }79 }80 return inst._debugID;81 };82 setChildrenForInstrumentation = function setChildrenForInstrumentation(children) {83 var debugID = getDebugID(this);84 if (debugID !== 0) {85 ReactInstrumentation.debugTool.onSetChildren(debugID, children ? Object.keys(children).map(function (key) {86 return children[key]._debugID;87 }) : []);88 }89 };90}91var ReactMultiChild = {92 _reconcilerInstantiateChildren: function _reconcilerInstantiateChildren(nestedChildren, transaction, context) {93 if (__DEV__) {94 var selfDebugID = getDebugID(this);95 if (this._currentElement) {96 try {97 ReactCurrentOwner.current = this._currentElement._owner;98 return ReactChildReconciler.instantiateChildren(nestedChildren, transaction, context, selfDebugID);99 } finally {100 ReactCurrentOwner.current = null;101 }102 }103 }104 return ReactChildReconciler.instantiateChildren(nestedChildren, transaction, context);105 },106 _reconcilerUpdateChildren: function _reconcilerUpdateChildren(prevChildren, nextNestedChildrenElements, mountImages, removedNodes, transaction, context) {107 var nextChildren;108 var selfDebugID = 0;109 if (__DEV__) {110 selfDebugID = getDebugID(this);111 if (this._currentElement) {112 try {113 ReactCurrentOwner.current = this._currentElement._owner;114 nextChildren = flattenChildren(nextNestedChildrenElements, selfDebugID);115 } finally {116 ReactCurrentOwner.current = null;117 }118 ReactChildReconciler.updateChildren(prevChildren, nextChildren, mountImages, removedNodes, transaction, this, this._hostContainerInfo, context, selfDebugID);119 return nextChildren;120 }121 }122 nextChildren = flattenChildren(nextNestedChildrenElements, selfDebugID);123 ReactChildReconciler.updateChildren(prevChildren, nextChildren, mountImages, removedNodes, transaction, this, this._hostContainerInfo, context, selfDebugID);124 return nextChildren;125 },126 mountChildren: function mountChildren(nestedChildren, transaction, context) {127 var children = this._reconcilerInstantiateChildren(nestedChildren, transaction, context);128 this._renderedChildren = children;129 var mountImages = [];130 var index = 0;131 for (var name in children) {132 if (children.hasOwnProperty(name)) {133 var child = children[name];134 var selfDebugID = 0;135 if (__DEV__) {136 selfDebugID = getDebugID(this);137 }138 var mountImage = ReactReconciler.mountComponent(child, transaction, this, this._hostContainerInfo, context, selfDebugID);139 child._mountIndex = index++;140 mountImages.push(mountImage);141 }142 }143 if (__DEV__) {144 setChildrenForInstrumentation.call(this, children);145 }146 return mountImages;147 },148 updateTextContent: function updateTextContent(nextContent) {149 var prevChildren = this._renderedChildren;150 ReactChildReconciler.unmountChildren(prevChildren, false);151 for (var name in prevChildren) {152 if (prevChildren.hasOwnProperty(name)) {153 invariant(false, 'updateTextContent called on non-empty component.');154 }155 }156 var updates = [makeTextContent(nextContent)];157 processQueue(this, updates);158 },159 updateMarkup: function updateMarkup(nextMarkup) {160 var prevChildren = this._renderedChildren;161 ReactChildReconciler.unmountChildren(prevChildren, false);162 for (var name in prevChildren) {163 if (prevChildren.hasOwnProperty(name)) {164 invariant(false, 'updateTextContent called on non-empty component.');165 }166 }167 var updates = [makeSetMarkup(nextMarkup)];168 processQueue(this, updates);169 },170 updateChildren: function updateChildren(nextNestedChildrenElements, transaction, context) {171 this._updateChildren(nextNestedChildrenElements, transaction, context);172 },173 _updateChildren: function _updateChildren(nextNestedChildrenElements, transaction, context) {174 var prevChildren = this._renderedChildren;175 var removedNodes = {};176 var mountImages = [];177 var nextChildren = this._reconcilerUpdateChildren(prevChildren, nextNestedChildrenElements, mountImages, removedNodes, transaction, context);178 if (!nextChildren && !prevChildren) {179 return;180 }181 var updates = null;182 var name;183 var nextIndex = 0;184 var lastIndex = 0;185 var nextMountIndex = 0;186 var lastPlacedNode = null;187 for (name in nextChildren) {188 if (!nextChildren.hasOwnProperty(name)) {189 continue;190 }191 var prevChild = prevChildren && prevChildren[name];192 var nextChild = nextChildren[name];193 if (prevChild === nextChild) {194 updates = enqueue(updates, this.moveChild(prevChild, lastPlacedNode, nextIndex, lastIndex));195 lastIndex = Math.max(prevChild._mountIndex, lastIndex);196 prevChild._mountIndex = nextIndex;197 } else {198 if (prevChild) {199 lastIndex = Math.max(prevChild._mountIndex, lastIndex);200 }201 updates = enqueue(updates, this._mountChildAtIndex(nextChild, mountImages[nextMountIndex], lastPlacedNode, nextIndex, transaction, context));202 nextMountIndex++;203 }204 nextIndex++;205 lastPlacedNode = ReactReconciler.getHostNode(nextChild);206 }207 for (name in removedNodes) {208 if (removedNodes.hasOwnProperty(name)) {209 updates = enqueue(updates, this._unmountChild(prevChildren[name], removedNodes[name]));210 }211 }212 if (updates) {213 processQueue(this, updates);214 }215 this._renderedChildren = nextChildren;216 if (__DEV__) {217 setChildrenForInstrumentation.call(this, nextChildren);218 }219 },220 unmountChildren: function unmountChildren(safely) {221 var renderedChildren = this._renderedChildren;222 ReactChildReconciler.unmountChildren(renderedChildren, safely);223 this._renderedChildren = null;224 },225 moveChild: function moveChild(child, afterNode, toIndex, lastIndex) {226 if (child._mountIndex < lastIndex) {227 return makeMove(child, afterNode, toIndex);228 }229 },230 createChild: function createChild(child, afterNode, mountImage) {231 return makeInsertMarkup(mountImage, afterNode, child._mountIndex);232 },233 removeChild: function removeChild(child, node) {234 return makeRemove(child, node);235 },236 _mountChildAtIndex: function _mountChildAtIndex(child, mountImage, afterNode, index, transaction, context) {237 child._mountIndex = index;238 return this.createChild(child, afterNode, mountImage);239 },240 _unmountChild: function _unmountChild(child, node) {241 var update = this.removeChild(child, node);242 child._mountIndex = null;243 return update;244 }245};...

Full Screen

Full Screen

41361dReactMultiChild.js

Source:41361dReactMultiChild.js Github

copy

Full Screen

...7var ReactChildReconciler=require('ReactChildReconciler');8var emptyFunction=require('fbjs/lib/emptyFunction');9var flattenChildren=require('flattenChildren');10var invariant=require('fbjs/lib/invariant');11function makeInsertMarkup(markup,afterNode,toIndex){12return{13type:'INSERT_MARKUP',14content:markup,15fromIndex:null,16fromNode:null,17toIndex:toIndex,18afterNode:afterNode};19}20function makeMove(child,afterNode,toIndex){21return{22type:'MOVE_EXISTING',23content:null,24fromIndex:child._mountIndex,25fromNode:ReactReconciler.getHostNode(child),26toIndex:toIndex,27afterNode:afterNode};28}29function makeRemove(child,node){30return{31type:'REMOVE_NODE',32content:null,33fromIndex:child._mountIndex,34fromNode:node,35toIndex:null,36afterNode:null};37}38function makeSetMarkup(markup){39return{40type:'SET_MARKUP',41content:markup,42fromIndex:null,43fromNode:null,44toIndex:null,45afterNode:null};46}47function makeTextContent(textContent){48return{49type:'TEXT_CONTENT',50content:textContent,51fromIndex:null,52fromNode:null,53toIndex:null,54afterNode:null};55}56function enqueue(queue,update){57if(update){58queue=queue||[];59queue.push(update);60}61return queue;62}63function processQueue(inst,updateQueue){64ReactComponentEnvironment.processChildrenUpdates(65inst,66updateQueue);67}68var setChildrenForInstrumentation=emptyFunction;69if(__DEV__){70var getDebugID=function getDebugID(inst){71if(!inst._debugID){72var internal;73if(internal=ReactInstanceMap.get(inst)){74inst=internal;75}76}77return inst._debugID;78};79setChildrenForInstrumentation=function setChildrenForInstrumentation(children){80var debugID=getDebugID(this);81if(debugID!==0){82ReactInstrumentation.debugTool.onSetChildren(83debugID,84children?Object.keys(children).map(function(key){return children[key]._debugID;}):[]);85}86};87}88var ReactMultiChild={89_reconcilerInstantiateChildren:function _reconcilerInstantiateChildren(nestedChildren,transaction,context){90if(__DEV__){91var selfDebugID=getDebugID(this);92if(this._currentElement){93try{94ReactCurrentOwner.current=this._currentElement._owner;95return ReactChildReconciler.instantiateChildren(96nestedChildren,transaction,context,selfDebugID);97}finally{98ReactCurrentOwner.current=null;99}100}101}102return ReactChildReconciler.instantiateChildren(103nestedChildren,transaction,context);104},105_reconcilerUpdateChildren:function _reconcilerUpdateChildren(106prevChildren,107nextNestedChildrenElements,108mountImages,109removedNodes,110transaction,111context)112{113var nextChildren;114var selfDebugID=0;115if(__DEV__){116selfDebugID=getDebugID(this);117if(this._currentElement){118try{119ReactCurrentOwner.current=this._currentElement._owner;120nextChildren=flattenChildren(nextNestedChildrenElements,selfDebugID);121}finally{122ReactCurrentOwner.current=null;123}124ReactChildReconciler.updateChildren(125prevChildren,126nextChildren,127mountImages,128removedNodes,129transaction,130this,131this._hostContainerInfo,132context,133selfDebugID);134return nextChildren;135}136}137nextChildren=flattenChildren(nextNestedChildrenElements,selfDebugID);138ReactChildReconciler.updateChildren(139prevChildren,140nextChildren,141mountImages,142removedNodes,143transaction,144this,145this._hostContainerInfo,146context,147selfDebugID);148return nextChildren;149},150mountChildren:function mountChildren(nestedChildren,transaction,context){151var children=this._reconcilerInstantiateChildren(152nestedChildren,transaction,context);153this._renderedChildren=children;154var mountImages=[];155var index=0;156for(var name in children){157if(children.hasOwnProperty(name)){158var child=children[name];159var selfDebugID=0;160if(__DEV__){161selfDebugID=getDebugID(this);162}163var mountImage=ReactReconciler.mountComponent(164child,165transaction,166this,167this._hostContainerInfo,168context,169selfDebugID);170child._mountIndex=index++;171mountImages.push(mountImage);172}173}174if(__DEV__){175setChildrenForInstrumentation.call(this,children);176}177return mountImages;178},179updateTextContent:function updateTextContent(nextContent){180var prevChildren=this._renderedChildren;181ReactChildReconciler.unmountChildren(prevChildren,false);182for(var name in prevChildren){183if(prevChildren.hasOwnProperty(name)){184invariant(false,'updateTextContent called on non-empty component.');185}186}187var updates=[makeTextContent(nextContent)];188processQueue(this,updates);189},190updateMarkup:function updateMarkup(nextMarkup){191var prevChildren=this._renderedChildren;192ReactChildReconciler.unmountChildren(prevChildren,false);193for(var name in prevChildren){194if(prevChildren.hasOwnProperty(name)){195invariant(false,'updateTextContent called on non-empty component.');196}197}198var updates=[makeSetMarkup(nextMarkup)];199processQueue(this,updates);200},201updateChildren:function updateChildren(nextNestedChildrenElements,transaction,context){202this._updateChildren(nextNestedChildrenElements,transaction,context);203},204_updateChildren:function _updateChildren(nextNestedChildrenElements,transaction,context){205var prevChildren=this._renderedChildren;206var removedNodes={};207var mountImages=[];208var nextChildren=this._reconcilerUpdateChildren(209prevChildren,210nextNestedChildrenElements,211mountImages,212removedNodes,213transaction,214context);215if(!nextChildren&&!prevChildren){216return;217}218var updates=null;219var name;220var nextIndex=0;221var lastIndex=0;222var nextMountIndex=0;223var lastPlacedNode=null;224for(name in nextChildren){225if(!nextChildren.hasOwnProperty(name)){226continue;227}228var prevChild=prevChildren&&prevChildren[name];229var nextChild=nextChildren[name];230if(prevChild===nextChild){231updates=enqueue(232updates,233this.moveChild(prevChild,lastPlacedNode,nextIndex,lastIndex));234lastIndex=Math.max(prevChild._mountIndex,lastIndex);235prevChild._mountIndex=nextIndex;236}else{237if(prevChild){238lastIndex=Math.max(prevChild._mountIndex,lastIndex);239}240updates=enqueue(241updates,242this._mountChildAtIndex(243nextChild,244mountImages[nextMountIndex],245lastPlacedNode,246nextIndex,247transaction,248context));249nextMountIndex++;250}251nextIndex++;252lastPlacedNode=ReactReconciler.getHostNode(nextChild);253}254for(name in removedNodes){255if(removedNodes.hasOwnProperty(name)){256updates=enqueue(257updates,258this._unmountChild(prevChildren[name],removedNodes[name]));259}260}261if(updates){262processQueue(this,updates);263}264this._renderedChildren=nextChildren;265if(__DEV__){266setChildrenForInstrumentation.call(this,nextChildren);267}268},269unmountChildren:function unmountChildren(safely){270var renderedChildren=this._renderedChildren;271ReactChildReconciler.unmountChildren(renderedChildren,safely);272this._renderedChildren=null;273},274moveChild:function moveChild(child,afterNode,toIndex,lastIndex){275if(child._mountIndex<lastIndex){276return makeMove(child,afterNode,toIndex);277}278},279createChild:function createChild(child,afterNode,mountImage){280return makeInsertMarkup(mountImage,afterNode,child._mountIndex);281},282removeChild:function removeChild(child,node){283return makeRemove(child,node);284},285_mountChildAtIndex:function _mountChildAtIndex(286child,287mountImage,288afterNode,289index,290transaction,291context){292child._mountIndex=index;293return this.createChild(child,afterNode,mountImage);294},...

Full Screen

Full Screen

6df2fcReactMultiChild.js

Source:6df2fcReactMultiChild.js Github

copy

Full Screen

...7var ReactChildReconciler=require('ReactChildReconciler');8var emptyFunction=require('fbjs/lib/emptyFunction');9var flattenChildren=require('flattenChildren');10var invariant=require('fbjs/lib/invariant');11function makeInsertMarkup(markup,afterNode,toIndex){12return{13type:'INSERT_MARKUP',14content:markup,15fromIndex:null,16fromNode:null,17toIndex:toIndex,18afterNode:afterNode};19}20function makeMove(child,afterNode,toIndex){21return{22type:'MOVE_EXISTING',23content:null,24fromIndex:child._mountIndex,25fromNode:ReactReconciler.getHostNode(child),26toIndex:toIndex,27afterNode:afterNode};28}29function makeRemove(child,node){30return{31type:'REMOVE_NODE',32content:null,33fromIndex:child._mountIndex,34fromNode:node,35toIndex:null,36afterNode:null};37}38function makeSetMarkup(markup){39return{40type:'SET_MARKUP',41content:markup,42fromIndex:null,43fromNode:null,44toIndex:null,45afterNode:null};46}47function makeTextContent(textContent){48return{49type:'TEXT_CONTENT',50content:textContent,51fromIndex:null,52fromNode:null,53toIndex:null,54afterNode:null};55}56function enqueue(queue,update){57if(update){58queue=queue||[];59queue.push(update);60}61return queue;62}63function processQueue(inst,updateQueue){64ReactComponentEnvironment.processChildrenUpdates(65inst,66updateQueue);67}68var setChildrenForInstrumentation=emptyFunction;69if(__DEV__){70var getDebugID=function getDebugID(inst){71if(!inst._debugID){72var internal;73if(internal=ReactInstanceMap.get(inst)){74inst=internal;75}76}77return inst._debugID;78};79setChildrenForInstrumentation=function setChildrenForInstrumentation(children){80var debugID=getDebugID(this);81if(debugID!==0){82ReactInstrumentation.debugTool.onSetChildren(83debugID,84children?Object.keys(children).map(function(key){return children[key]._debugID;}):[]);85}86};87}88var ReactMultiChild={89_reconcilerInstantiateChildren:function _reconcilerInstantiateChildren(nestedChildren,transaction,context){90if(__DEV__){91var selfDebugID=getDebugID(this);92if(this._currentElement){93try{94ReactCurrentOwner.current=this._currentElement._owner;95return ReactChildReconciler.instantiateChildren(96nestedChildren,transaction,context,selfDebugID);97}finally{98ReactCurrentOwner.current=null;99}100}101}102return ReactChildReconciler.instantiateChildren(103nestedChildren,transaction,context);104},105_reconcilerUpdateChildren:function _reconcilerUpdateChildren(106prevChildren,107nextNestedChildrenElements,108mountImages,109removedNodes,110transaction,111context)112{113var nextChildren;114var selfDebugID=0;115if(__DEV__){116selfDebugID=getDebugID(this);117if(this._currentElement){118try{119ReactCurrentOwner.current=this._currentElement._owner;120nextChildren=flattenChildren(nextNestedChildrenElements,selfDebugID);121}finally{122ReactCurrentOwner.current=null;123}124ReactChildReconciler.updateChildren(125prevChildren,126nextChildren,127mountImages,128removedNodes,129transaction,130this,131this._hostContainerInfo,132context,133selfDebugID);134return nextChildren;135}136}137nextChildren=flattenChildren(nextNestedChildrenElements,selfDebugID);138ReactChildReconciler.updateChildren(139prevChildren,140nextChildren,141mountImages,142removedNodes,143transaction,144this,145this._hostContainerInfo,146context,147selfDebugID);148return nextChildren;149},150mountChildren:function mountChildren(nestedChildren,transaction,context){151var children=this._reconcilerInstantiateChildren(152nestedChildren,transaction,context);153this._renderedChildren=children;154var mountImages=[];155var index=0;156for(var name in children){157if(children.hasOwnProperty(name)){158var child=children[name];159var selfDebugID=0;160if(__DEV__){161selfDebugID=getDebugID(this);162}163var mountImage=ReactReconciler.mountComponent(164child,165transaction,166this,167this._hostContainerInfo,168context,169selfDebugID);170child._mountIndex=index++;171mountImages.push(mountImage);172}173}174if(__DEV__){175setChildrenForInstrumentation.call(this,children);176}177return mountImages;178},179updateTextContent:function updateTextContent(nextContent){180var prevChildren=this._renderedChildren;181ReactChildReconciler.unmountChildren(prevChildren,false);182for(var name in prevChildren){183if(prevChildren.hasOwnProperty(name)){184invariant(false,'updateTextContent called on non-empty component.');185}186}187var updates=[makeTextContent(nextContent)];188processQueue(this,updates);189},190updateMarkup:function updateMarkup(nextMarkup){191var prevChildren=this._renderedChildren;192ReactChildReconciler.unmountChildren(prevChildren,false);193for(var name in prevChildren){194if(prevChildren.hasOwnProperty(name)){195invariant(false,'updateTextContent called on non-empty component.');196}197}198var updates=[makeSetMarkup(nextMarkup)];199processQueue(this,updates);200},201updateChildren:function updateChildren(nextNestedChildrenElements,transaction,context){202this._updateChildren(nextNestedChildrenElements,transaction,context);203},204_updateChildren:function _updateChildren(nextNestedChildrenElements,transaction,context){205var prevChildren=this._renderedChildren;206var removedNodes={};207var mountImages=[];208var nextChildren=this._reconcilerUpdateChildren(209prevChildren,210nextNestedChildrenElements,211mountImages,212removedNodes,213transaction,214context);215if(!nextChildren&&!prevChildren){216return;217}218var updates=null;219var name;220var nextIndex=0;221var lastIndex=0;222var nextMountIndex=0;223var lastPlacedNode=null;224for(name in nextChildren){225if(!nextChildren.hasOwnProperty(name)){226continue;227}228var prevChild=prevChildren&&prevChildren[name];229var nextChild=nextChildren[name];230if(prevChild===nextChild){231updates=enqueue(232updates,233this.moveChild(prevChild,lastPlacedNode,nextIndex,lastIndex));234lastIndex=Math.max(prevChild._mountIndex,lastIndex);235prevChild._mountIndex=nextIndex;236}else{237if(prevChild){238lastIndex=Math.max(prevChild._mountIndex,lastIndex);239}240updates=enqueue(241updates,242this._mountChildAtIndex(243nextChild,244mountImages[nextMountIndex],245lastPlacedNode,246nextIndex,247transaction,248context));249nextMountIndex++;250}251nextIndex++;252lastPlacedNode=ReactReconciler.getHostNode(nextChild);253}254for(name in removedNodes){255if(removedNodes.hasOwnProperty(name)){256updates=enqueue(257updates,258this._unmountChild(prevChildren[name],removedNodes[name]));259}260}261if(updates){262processQueue(this,updates);263}264this._renderedChildren=nextChildren;265if(__DEV__){266setChildrenForInstrumentation.call(this,nextChildren);267}268},269unmountChildren:function unmountChildren(safely){270var renderedChildren=this._renderedChildren;271ReactChildReconciler.unmountChildren(renderedChildren,safely);272this._renderedChildren=null;273},274moveChild:function moveChild(child,afterNode,toIndex,lastIndex){275if(child._mountIndex<lastIndex){276return makeMove(child,afterNode,toIndex);277}278},279createChild:function createChild(child,afterNode,mountImage){280return makeInsertMarkup(mountImage,afterNode,child._mountIndex);281},282removeChild:function removeChild(child,node){283return makeRemove(child,node);284},285_mountChildAtIndex:function _mountChildAtIndex(286child,287mountImage,288afterNode,289index,290transaction,291context){292child._mountIndex=index;293return this.createChild(child,afterNode,mountImage);294},...

Full Screen

Full Screen

4bcd29ReactMultiChild.js

Source:4bcd29ReactMultiChild.js Github

copy

Full Screen

...7var ReactChildReconciler=require('ReactChildReconciler');8var emptyFunction=require('fbjs/lib/emptyFunction');9var flattenChildren=require('flattenChildren');10var invariant=require('fbjs/lib/invariant');11function makeInsertMarkup(markup,afterNode,toIndex){12return{13type:'INSERT_MARKUP',14content:markup,15fromIndex:null,16fromNode:null,17toIndex:toIndex,18afterNode:afterNode};19}20function makeMove(child,afterNode,toIndex){21return{22type:'MOVE_EXISTING',23content:null,24fromIndex:child._mountIndex,25fromNode:ReactReconciler.getHostNode(child),26toIndex:toIndex,27afterNode:afterNode};28}29function makeRemove(child,node){30return{31type:'REMOVE_NODE',32content:null,33fromIndex:child._mountIndex,34fromNode:node,35toIndex:null,36afterNode:null};37}38function makeSetMarkup(markup){39return{40type:'SET_MARKUP',41content:markup,42fromIndex:null,43fromNode:null,44toIndex:null,45afterNode:null};46}47function makeTextContent(textContent){48return{49type:'TEXT_CONTENT',50content:textContent,51fromIndex:null,52fromNode:null,53toIndex:null,54afterNode:null};55}56function enqueue(queue,update){57if(update){58queue=queue||[];59queue.push(update);60}61return queue;62}63function processQueue(inst,updateQueue){64ReactComponentEnvironment.processChildrenUpdates(65inst,66updateQueue);67}68var setChildrenForInstrumentation=emptyFunction;69if(__DEV__){70var getDebugID=function getDebugID(inst){71if(!inst._debugID){72var internal;73if(internal=ReactInstanceMap.get(inst)){74inst=internal;75}76}77return inst._debugID;78};79setChildrenForInstrumentation=function setChildrenForInstrumentation(children){80var debugID=getDebugID(this);81if(debugID!==0){82ReactInstrumentation.debugTool.onSetChildren(83debugID,84children?Object.keys(children).map(function(key){return children[key]._debugID;}):[]);85}86};87}88var ReactMultiChild={89_reconcilerInstantiateChildren:function _reconcilerInstantiateChildren(nestedChildren,transaction,context){90if(__DEV__){91var selfDebugID=getDebugID(this);92if(this._currentElement){93try{94ReactCurrentOwner.current=this._currentElement._owner;95return ReactChildReconciler.instantiateChildren(96nestedChildren,transaction,context,selfDebugID);97}finally{98ReactCurrentOwner.current=null;99}100}101}102return ReactChildReconciler.instantiateChildren(103nestedChildren,transaction,context);104},105_reconcilerUpdateChildren:function _reconcilerUpdateChildren(106prevChildren,107nextNestedChildrenElements,108mountImages,109removedNodes,110transaction,111context)112{113var nextChildren;114var selfDebugID=0;115if(__DEV__){116selfDebugID=getDebugID(this);117if(this._currentElement){118try{119ReactCurrentOwner.current=this._currentElement._owner;120nextChildren=flattenChildren(nextNestedChildrenElements,selfDebugID);121}finally{122ReactCurrentOwner.current=null;123}124ReactChildReconciler.updateChildren(125prevChildren,126nextChildren,127mountImages,128removedNodes,129transaction,130this,131this._hostContainerInfo,132context,133selfDebugID);134return nextChildren;135}136}137nextChildren=flattenChildren(nextNestedChildrenElements,selfDebugID);138ReactChildReconciler.updateChildren(139prevChildren,140nextChildren,141mountImages,142removedNodes,143transaction,144this,145this._hostContainerInfo,146context,147selfDebugID);148return nextChildren;149},150mountChildren:function mountChildren(nestedChildren,transaction,context){151var children=this._reconcilerInstantiateChildren(152nestedChildren,transaction,context);153this._renderedChildren=children;154var mountImages=[];155var index=0;156for(var name in children){157if(children.hasOwnProperty(name)){158var child=children[name];159var selfDebugID=0;160if(__DEV__){161selfDebugID=getDebugID(this);162}163var mountImage=ReactReconciler.mountComponent(164child,165transaction,166this,167this._hostContainerInfo,168context,169selfDebugID);170child._mountIndex=index++;171mountImages.push(mountImage);172}173}174if(__DEV__){175setChildrenForInstrumentation.call(this,children);176}177return mountImages;178},179updateTextContent:function updateTextContent(nextContent){180var prevChildren=this._renderedChildren;181ReactChildReconciler.unmountChildren(prevChildren,false);182for(var name in prevChildren){183if(prevChildren.hasOwnProperty(name)){184invariant(false,'updateTextContent called on non-empty component.');185}186}187var updates=[makeTextContent(nextContent)];188processQueue(this,updates);189},190updateMarkup:function updateMarkup(nextMarkup){191var prevChildren=this._renderedChildren;192ReactChildReconciler.unmountChildren(prevChildren,false);193for(var name in prevChildren){194if(prevChildren.hasOwnProperty(name)){195invariant(false,'updateTextContent called on non-empty component.');196}197}198var updates=[makeSetMarkup(nextMarkup)];199processQueue(this,updates);200},201updateChildren:function updateChildren(nextNestedChildrenElements,transaction,context){202this._updateChildren(nextNestedChildrenElements,transaction,context);203},204_updateChildren:function _updateChildren(nextNestedChildrenElements,transaction,context){205var prevChildren=this._renderedChildren;206var removedNodes={};207var mountImages=[];208var nextChildren=this._reconcilerUpdateChildren(209prevChildren,210nextNestedChildrenElements,211mountImages,212removedNodes,213transaction,214context);215if(!nextChildren&&!prevChildren){216return;217}218var updates=null;219var name;220var nextIndex=0;221var lastIndex=0;222var nextMountIndex=0;223var lastPlacedNode=null;224for(name in nextChildren){225if(!nextChildren.hasOwnProperty(name)){226continue;227}228var prevChild=prevChildren&&prevChildren[name];229var nextChild=nextChildren[name];230if(prevChild===nextChild){231updates=enqueue(232updates,233this.moveChild(prevChild,lastPlacedNode,nextIndex,lastIndex));234lastIndex=Math.max(prevChild._mountIndex,lastIndex);235prevChild._mountIndex=nextIndex;236}else{237if(prevChild){238lastIndex=Math.max(prevChild._mountIndex,lastIndex);239}240updates=enqueue(241updates,242this._mountChildAtIndex(243nextChild,244mountImages[nextMountIndex],245lastPlacedNode,246nextIndex,247transaction,248context));249nextMountIndex++;250}251nextIndex++;252lastPlacedNode=ReactReconciler.getHostNode(nextChild);253}254for(name in removedNodes){255if(removedNodes.hasOwnProperty(name)){256updates=enqueue(257updates,258this._unmountChild(prevChildren[name],removedNodes[name]));259}260}261if(updates){262processQueue(this,updates);263}264this._renderedChildren=nextChildren;265if(__DEV__){266setChildrenForInstrumentation.call(this,nextChildren);267}268},269unmountChildren:function unmountChildren(safely){270var renderedChildren=this._renderedChildren;271ReactChildReconciler.unmountChildren(renderedChildren,safely);272this._renderedChildren=null;273},274moveChild:function moveChild(child,afterNode,toIndex,lastIndex){275if(child._mountIndex<lastIndex){276return makeMove(child,afterNode,toIndex);277}278},279createChild:function createChild(child,afterNode,mountImage){280return makeInsertMarkup(mountImage,afterNode,child._mountIndex);281},282removeChild:function removeChild(child,node){283return makeRemove(child,node);284},285_mountChildAtIndex:function _mountChildAtIndex(286child,287mountImage,288afterNode,289index,290transaction,291context){292child._mountIndex=index;293return this.createChild(child,afterNode,mountImage);294},...

Full Screen

Full Screen

583b23ReactMultiChild.js

Source:583b23ReactMultiChild.js Github

copy

Full Screen

...7var ReactChildReconciler=require('ReactChildReconciler');8var emptyFunction=require('fbjs/lib/emptyFunction');9var flattenChildren=require('flattenChildren');10var invariant=require('fbjs/lib/invariant');11function makeInsertMarkup(markup,afterNode,toIndex){12return{13type:'INSERT_MARKUP',14content:markup,15fromIndex:null,16fromNode:null,17toIndex:toIndex,18afterNode:afterNode};19}20function makeMove(child,afterNode,toIndex){21return{22type:'MOVE_EXISTING',23content:null,24fromIndex:child._mountIndex,25fromNode:ReactReconciler.getHostNode(child),26toIndex:toIndex,27afterNode:afterNode};28}29function makeRemove(child,node){30return{31type:'REMOVE_NODE',32content:null,33fromIndex:child._mountIndex,34fromNode:node,35toIndex:null,36afterNode:null};37}38function makeSetMarkup(markup){39return{40type:'SET_MARKUP',41content:markup,42fromIndex:null,43fromNode:null,44toIndex:null,45afterNode:null};46}47function makeTextContent(textContent){48return{49type:'TEXT_CONTENT',50content:textContent,51fromIndex:null,52fromNode:null,53toIndex:null,54afterNode:null};55}56function enqueue(queue,update){57if(update){58queue=queue||[];59queue.push(update);60}61return queue;62}63function processQueue(inst,updateQueue){64ReactComponentEnvironment.processChildrenUpdates(65inst,66updateQueue);67}68var setChildrenForInstrumentation=emptyFunction;69if(__DEV__){70var getDebugID=function getDebugID(inst){71if(!inst._debugID){72var internal;73if(internal=ReactInstanceMap.get(inst)){74inst=internal;75}76}77return inst._debugID;78};79setChildrenForInstrumentation=function setChildrenForInstrumentation(children){80var debugID=getDebugID(this);81if(debugID!==0){82ReactInstrumentation.debugTool.onSetChildren(83debugID,84children?Object.keys(children).map(function(key){return children[key]._debugID;}):[]);85}86};87}88var ReactMultiChild={89_reconcilerInstantiateChildren:function _reconcilerInstantiateChildren(nestedChildren,transaction,context){90if(__DEV__){91var selfDebugID=getDebugID(this);92if(this._currentElement){93try{94ReactCurrentOwner.current=this._currentElement._owner;95return ReactChildReconciler.instantiateChildren(96nestedChildren,transaction,context,selfDebugID);97}finally{98ReactCurrentOwner.current=null;99}100}101}102return ReactChildReconciler.instantiateChildren(103nestedChildren,transaction,context);104},105_reconcilerUpdateChildren:function _reconcilerUpdateChildren(106prevChildren,107nextNestedChildrenElements,108mountImages,109removedNodes,110transaction,111context)112{113var nextChildren;114var selfDebugID=0;115if(__DEV__){116selfDebugID=getDebugID(this);117if(this._currentElement){118try{119ReactCurrentOwner.current=this._currentElement._owner;120nextChildren=flattenChildren(nextNestedChildrenElements,selfDebugID);121}finally{122ReactCurrentOwner.current=null;123}124ReactChildReconciler.updateChildren(125prevChildren,126nextChildren,127mountImages,128removedNodes,129transaction,130this,131this._hostContainerInfo,132context,133selfDebugID);134return nextChildren;135}136}137nextChildren=flattenChildren(nextNestedChildrenElements,selfDebugID);138ReactChildReconciler.updateChildren(139prevChildren,140nextChildren,141mountImages,142removedNodes,143transaction,144this,145this._hostContainerInfo,146context,147selfDebugID);148return nextChildren;149},150mountChildren:function mountChildren(nestedChildren,transaction,context){151var children=this._reconcilerInstantiateChildren(152nestedChildren,transaction,context);153this._renderedChildren=children;154var mountImages=[];155var index=0;156for(var name in children){157if(children.hasOwnProperty(name)){158var child=children[name];159var selfDebugID=0;160if(__DEV__){161selfDebugID=getDebugID(this);162}163var mountImage=ReactReconciler.mountComponent(164child,165transaction,166this,167this._hostContainerInfo,168context,169selfDebugID);170child._mountIndex=index++;171mountImages.push(mountImage);172}173}174if(__DEV__){175setChildrenForInstrumentation.call(this,children);176}177return mountImages;178},179updateTextContent:function updateTextContent(nextContent){180var prevChildren=this._renderedChildren;181ReactChildReconciler.unmountChildren(prevChildren,false);182for(var name in prevChildren){183if(prevChildren.hasOwnProperty(name)){184invariant(false,'updateTextContent called on non-empty component.');185}186}187var updates=[makeTextContent(nextContent)];188processQueue(this,updates);189},190updateMarkup:function updateMarkup(nextMarkup){191var prevChildren=this._renderedChildren;192ReactChildReconciler.unmountChildren(prevChildren,false);193for(var name in prevChildren){194if(prevChildren.hasOwnProperty(name)){195invariant(false,'updateTextContent called on non-empty component.');196}197}198var updates=[makeSetMarkup(nextMarkup)];199processQueue(this,updates);200},201updateChildren:function updateChildren(nextNestedChildrenElements,transaction,context){202this._updateChildren(nextNestedChildrenElements,transaction,context);203},204_updateChildren:function _updateChildren(nextNestedChildrenElements,transaction,context){205var prevChildren=this._renderedChildren;206var removedNodes={};207var mountImages=[];208var nextChildren=this._reconcilerUpdateChildren(209prevChildren,210nextNestedChildrenElements,211mountImages,212removedNodes,213transaction,214context);215if(!nextChildren&&!prevChildren){216return;217}218var updates=null;219var name;220var nextIndex=0;221var lastIndex=0;222var nextMountIndex=0;223var lastPlacedNode=null;224for(name in nextChildren){225if(!nextChildren.hasOwnProperty(name)){226continue;227}228var prevChild=prevChildren&&prevChildren[name];229var nextChild=nextChildren[name];230if(prevChild===nextChild){231updates=enqueue(232updates,233this.moveChild(prevChild,lastPlacedNode,nextIndex,lastIndex));234lastIndex=Math.max(prevChild._mountIndex,lastIndex);235prevChild._mountIndex=nextIndex;236}else{237if(prevChild){238lastIndex=Math.max(prevChild._mountIndex,lastIndex);239}240updates=enqueue(241updates,242this._mountChildAtIndex(243nextChild,244mountImages[nextMountIndex],245lastPlacedNode,246nextIndex,247transaction,248context));249nextMountIndex++;250}251nextIndex++;252lastPlacedNode=ReactReconciler.getHostNode(nextChild);253}254for(name in removedNodes){255if(removedNodes.hasOwnProperty(name)){256updates=enqueue(257updates,258this._unmountChild(prevChildren[name],removedNodes[name]));259}260}261if(updates){262processQueue(this,updates);263}264this._renderedChildren=nextChildren;265if(__DEV__){266setChildrenForInstrumentation.call(this,nextChildren);267}268},269unmountChildren:function unmountChildren(safely){270var renderedChildren=this._renderedChildren;271ReactChildReconciler.unmountChildren(renderedChildren,safely);272this._renderedChildren=null;273},274moveChild:function moveChild(child,afterNode,toIndex,lastIndex){275if(child._mountIndex<lastIndex){276return makeMove(child,afterNode,toIndex);277}278},279createChild:function createChild(child,afterNode,mountImage){280return makeInsertMarkup(mountImage,afterNode,child._mountIndex);281},282removeChild:function removeChild(child,node){283return makeRemove(child,node);284},285_mountChildAtIndex:function _mountChildAtIndex(286child,287mountImage,288afterNode,289index,290transaction,291context){292child._mountIndex=index;293return this.createChild(child,afterNode,mountImage);294},...

Full Screen

Full Screen

Diff_Source.js

Source:Diff_Source.js Github

copy

Full Screen

...23 }24};25/**************element diff*********/26// 对同一层级的节点,提供3种节点操作,分别为INSERT_MARKUP,MOVE_EXISTING,REMOVE_NODE27function makeInsertMarkup(markup, afterNode, toIndex) {28 return {29 type: ReactMultiChildUpdateTypes.INSERT_MARKUP,30 content: markup,31 fromIndex: null,32 fromNode: null,33 toIndex: toIndex,34 afterNode: afterNode,35 };36}37function makeMove(child, afterNode, toIndex) {38 return {39 type: ReactMultiChildUpdateTypes.MOVE_EXISTING,40 content: null,41 fromIndex: child._mountIndex,42 fromNode: ReactReconciler.getNativeNode(child),43 toIndex: toIndex,44 afterNode: afterNode,45 };46}47function makeRemove(child, node) {48 return {49 type: ReactMultiChildUpdateTypes.REMOVE_NODE,50 content: null,51 fromIndex: child._mountIndex,52 fromNode: node,53 toIndex: null,54 afterNode: null,55 };56}57/**************diff算法的核心*********/58const diff = {59 _updateChildren: function(nextNestedChildrenElements, transaction, context) {60 var prevChildren = this._renderedChildren;61 var removedNodes = {};62 var nextChildren = this._reconcilerUpdateChildren(prevChildren, nextNestedChildrenElements,63 removedNodes, transaction, context);64 if (!nextChildren && !prevChildren) {65 return;66 }67 var updates = null;68 var name;69 var lastIndex = 0;70 var nextIndex = 0;71 var lastPlacedNode = null;72 //遍历新的节点集合73 for (name in nextChildren) {74 if (!nextChildren.hasOwnProperty(name)) {75 continue;76 }77 var prevChild = prevChildren && prevChildren[name];78 var nextChild = nextChildren[name];79 if (prevChild === nextChild) {80 updates = enqueue(81 updates,82 this.moveChild(prevChild, lastPlacedNode, nextIndex, lastIndex)83 );84 lastIndex = Math.max(prevChild._mountIndex, lastIndex);85 prevChild._mountIndex = nextIndex;86 } else {87 if (prevChild) {88 lastIndex = Math.max(prevChild._mountIndex, lastIndex);89 }90 updates = enqueue(91 updates,92 this._mountChildAtIndex(nextChild, lastPlacedNode, nextIndex, transaction, context)93 );94 }95 nextIndex++;96 lastPlacedNode = ReactReconciler.getNativeNode(nextChild);97 }98 for (name in removedNodes) {99 if (removedNodes.hasOwnProperty(name)) {100 updates = enqueue(101 updates,102 this._unmountChild(prevChildren[name], removedNodes[name])103 );104 }105 }106 if (updates) {107 processQueue(this, updates);108 }109 this._renderedChildren = nextChildren;110 },111 moveChild: function(child, afterNode, toIndex, lastIndex) {112 if (child._mountIndex < lastIndex) {113 return makeMove(child, afterNode, toIndex);114 }115 },116 createChild: function(child, afterNode, mountImage) {117 return makeInsertMarkup(mountImage, afterNode, child._mountIndex);118 },119 removeChild: function(child, node) {120 return makeRemove(child, node);121 },122 _unmountChild: function(child, node) {123 var update = this.removeChild(child, node);124 child._mountIndex = null;125 return update;126 },127 _mountChildAtIndex: function(child, afterNode, index, transaction, context) {128 var mountImage = ReactReconciler.mountComponent(child, transaction, this, this._nativeContainerInfo,129 context);130 child._mountIndex = index;131 return this.createChild(child, afterNode, mountImage);...

Full Screen

Full Screen

ReactMultiChild.js

Source:ReactMultiChild.js Github

copy

Full Screen

...31}32function processQueue(inst, updateQueue) {33 ReactComponentEnvironment.processChildrenUpdates(inst, updateQueue);34}35function makeInsertMarkup(markup, afterNode, toIndex) {36 return {37 type: 'INSERT_MARKUP',38 content: markup,39 fromIndex: null,40 fromNode: null,41 toIndex,42 afterNode,43 };44}45var ReactMultiChild = {46 Mixin: {47 mountChildren(48 nestedChildren,49 transaction,50 context,51 ) {52 var children = this._reconcilerInstantiateChildren(nestedChildren);53 this._renderedChildren = children;54 var mountImages = [];55 var index = 0;56 for (var name in children) {57 if (children.hasOwnProperty(name)) {58 var child = children[name];59 var mountImage = ReactReconciler.mountComponent(60 child,61 transaction,62 this,63 this._hostContainerInfo,64 context,65 );66 mountImages.push(mountImage);67 }68 }69 return mountImages;70 },71 updateChildren(72 nextNestedChildrenElements,73 transaction,74 context75 ) {76 this._updateChildren(nextNestedChildrenElements, transaction, context);77 },78 unmountChildren(safely) {79 var _renderedChildren = this._renderedChildren;80 ReactChildReconciler.unmountChildren(_renderedChildren, safely);81 this._renderedChildren = null;82 },83 moveChild(84 child,85 afterNode,86 toIndex,87 lastIndex,88 ) {89 if (child._mountIndex < lastIndex) {90 return makeMove(child, afterNode, toIndex);91 }92 },93 removeChild(child, node) {94 return makeRemove(child, node);95 },96 _updateChildren(97 nextNestedChildrenElements,98 transaction,99 context,100 ) {101 var prevChildren = this._renderedChildren;102 var removedNodes = {};103 var mountImages = [];104 var nextChildren = this._reconcilerUpdateChildren(105 prevChildren,106 nextNestedChildrenElements,107 mountImages,108 removedNodes,109 transaction,110 context,111 );112 if (!nextChildren && !prevChildren) {113 return;114 }115 var updates = null;116 var name;117 var nextIndex = 0;118 var lastIndex = 0;119 var nextMountIndex = 0;120 var lastPlacedNode = null;121 for (name in nextChildren) {122 if (!nextChildren.hasOwnProperty(name)) {123 continue;124 }125 var prevChild = prevChildren && prevChildren[name];126 var nextChild = nextChildren[name];127 if (prevChild === nextChild) {128 updates = enqueue(129 updates,130 this.moveChild(prevChild, lastPlacedNode, nextIndex, lastIndex)131 );132 lastIndex = Math.max(prevChild._mountIndex, lastIndex);133 prevChild._mountIndex = nextIndex;134 } else {135 if (prevChild) {136 lastIndex = Math.max(prevChild._mountIndex, lastIndex);137 }138 updates = enqueue(139 updates,140 this._mountChildAtIndex(141 nextChild,142 mountImages[nextMountIndex],143 lastPlacedNode,144 nextIndex,145 transaction,146 context147 )148 );149 nextMountIndex++;150 }151 nextIndex++;152 lastPlacedNode = ReactReconciler.getHostNode(nextChild);153 }154 for (name in removedNodes) {155 if (removedNodes.hasOwnProperty(name)) {156 updates = enqueue(157 updates,158 this._unmountChild(prevChildren[name], removedNodes[name])159 );160 }161 }162 if (updates) {163 processQueue(this, updates);164 }165 this._renderedChildren = nextChildren;166 },167 _reconcilerUpdateChildren(168 prevChildren,169 nextNestedChildrenElements,170 mountImages,171 removedNodes,172 transaction,173 context174 ) {175 var nextChildren;176 nextChildren = flattenChildren(nextNestedChildrenElements);177 ReactChildReconciler.updateChildren(178 prevChildren,179 nextChildren,180 mountImages,181 removedNodes,182 transaction,183 this,184 this._hostContainerInfo,185 context,186 );187 return nextChildren;188 },189 _reconcilerInstantiateChildren(nestedChildren) {190 return ReactChildReconciler.instantiateChildren(nestedChildren);191 },192 _mountChildAtIndex(193 child,194 mountImage,195 afterNode,196 index,197 transaction,198 context199 ) {200 child._mountIndex = index;201 return this.createChild(child, afterNode, mountImage);202 },203 createChild(child, afterNode, mountImage) {204 return makeInsertMarkup(mountImage, afterNode, child._mountIndex);205 },206 _unmountChild(child, node) {207 var update = this.removeChild(child, node);208 child._mountIndex = null;209 return update;210 }211 }212};...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const {makeInsertMarkup} = require('playwright/lib/internal/inspectorInstrumentation');2const {makeInsertMarkup} = require('playwright/lib/internal/inspectorInstrumentation');3const {makeInsertMarkup} = require('playwright/lib/internal/inspectorInstrumentation');4const {makeInsertMarkup} = require('playwright/lib/internal/inspectorInstrumentation');5const {makeInsertMarkup} = require('playwright/lib/internal/inspectorInstrumentation');6const {makeInsertMarkup} = require('playwright/lib/internal/inspectorInstrumentation');7const {makeInsertMarkup} = require('playwright/lib/internal/inspectorInstrumentation');8const {makeInsertMarkup} = require('playwright/lib/internal/inspectorInstrumentation');9const {makeInsertMarkup} = require('playwright/lib/internal/inspectorInstrumentation');10const {makeInsertMarkup} = require('playwright/lib/internal/inspectorInstrumentation');11const {makeInsertMarkup} = require('playwright/lib/internal/inspectorInstrumentation');12const {makeInsertMarkup} = require('playwright/lib/internal/inspectorInstrumentation');13const {makeInsertMarkup} = require('playwright/lib/internal/inspectorInstrumentation');14const {makeInsertMarkup} = require('playwright/lib/internal/inspectorInstrumentation');15const {makeInsertMarkup} = require('playwright/lib/internal/inspectorInstrumentation');16const {

Full Screen

Using AI Code Generation

copy

Full Screen

1const { makeInsertMarkup } = require('@playwright/test/lib/server/injected/injectedScript');2const { makeInsertMarkup } = require('@playwright/test/lib/server/injected/injectedScript');3const markup = makeInsertMarkup('some text', 'some css');4console.log(markup);5const { makeInsertMarkup } = require('@playwright/test/lib/server/injected/injectedScript');6const markup = makeInsertMarkup('some text', 'some css');7console.log(markup);8const { makeInsertMarkup } = require('@playwright/test/lib/server/injected/injectedScript');9const markup = makeInsertMarkup('some text', 'some css');10console.log(markup);11const { makeInsertMarkup } = require('@playwright/test/lib/server/injected/injectedScript');12const markup = makeInsertMarkup('some text', 'some css');13console.log(markup);14const { makeInsertMarkup } = require('@playwright/test/lib/server/injected/injectedScript');15const markup = makeInsertMarkup('some text', 'some css');16console.log(markup);17const { makeInsertMarkup } = require('@playwright/test/lib/server/injected/injectedScript');18const markup = makeInsertMarkup('some text', 'some css');19console.log(markup);20const { makeInsertMarkup } = require('@playwright/test/lib/server/injected/injectedScript');21const markup = makeInsertMarkup('some text', 'some css

Full Screen

Using AI Code Generation

copy

Full Screen

1const { makeInsertMarkup } = require('playwright/lib/server/dom.js');2const { parseHTML } = require('playwright/lib/server/common/html.js');3const { serializeNode } = require('playwright/lib/server/common/serializers.js');4const { createJSHandle } = require('playwright/lib/server/common/jshandle.js');5const { ElementHandle } = require('playwright/lib/server/dom.js');6const { JSHandle } = require('playwright/lib/server/common/jshandle.js');7const { makeInsertMarkup } = require('playwright/lib/server/dom.js');8const { parseHTML } = require('playwright/lib/server/common/html.js');9const { serializeNode } = require('playwright/lib/server/common/serializers.js');10const { createJSHandle } = require('playwright/lib/server/common/jshandle.js');11const { ElementHandle } = require('playwright/lib/server/dom.js');12const { JSHandle } = require('playwright/lib/server/common/jshandle.js');13const { makeInsertMarkup } = require('playwright/lib/server/dom.js');14const { parseHTML } = require('playwright/lib/server/common/html.js');15const { serializeNode } = require('playwright/lib/server/common/serializers.js');16const { createJSHandle } = require('playwright/lib/server/common/jshandle.js');17const { ElementHandle } = require('playwright/lib/server/dom.js');18const { JSHandle } = require('playwright/lib/server/common/jshandle.js');19const { makeInsertMarkup } = require('playwright/lib/server/dom.js');20const { parseHTML } = require('playwright/lib/server/common/html.js');21const { serializeNode } = require('playwright/lib/server/common/serializers.js');22const { createJSHandle } = require('playwright/lib/server/common/jshandle.js');23const { ElementHandle } = require('playwright/lib/server/dom.js');24const { JSHandle } = require('playwright/lib/server/common/jshandle.js');25const { makeInsertMarkup } = require('playwright/lib/server/dom.js');26const { parseHTML } = require('playwright/lib/server/common/html.js');

Full Screen

Using AI Code Generation

copy

Full Screen

1import { makeInsertMarkup } from 'playwright-core/lib/server/supplements/recorder/recorderSupplement';2const insertMarkup = makeInsertMarkup();3await page.evaluate(insertMarkup, 'button', 'click', 'span', 'innerText', 'Hello World!');4await page.evaluate(insertMarkup, 'button', 'click', 'span', 'innerText', 'Hello World!', {waitFor: 'visible'});5await page.evaluate(insertMarkup, 'button', 'click', 'span', 'innerText', 'Hello World!', {waitFor: 'visible', timeout: 5000});6await page.evaluate(insertMarkup, 'button', 'click', 'span', 'innerText', 'Hello World!', {waitFor: 'visible', timeout: 5000}, {waitFor: 'visible', timeout: 5000});7await page.evaluate(insertMarkup, 'button', 'click', 'span', 'innerText', 'Hello World!', {waitFor: 'visible', timeout: 5000}, {waitFor: 'visible', timeout: 5000}, {waitFor: 'visible', timeout: 5000});8await page.evaluate(insertMarkup, 'button', 'click', 'span', 'innerText', 'Hello World!', {waitFor: 'visible', timeout: 5000}, {waitFor: 'visible', timeout: 5000}, {waitFor: 'visible', timeout: 5000}, {waitFor: 'visible', timeout: 5000});

Full Screen

Using AI Code Generation

copy

Full Screen

1const { makeInsertMarkup } = require('playwright/lib/internal/injected/injectedScript');2makeInsertMarkup(document, 'body', '<div id="test">Hello World</div>');3const testDiv = await page.$('#test');4expect(await testDiv.innerText()).toBe('Hello World');5const { chromium } = require('playwright');6(async () => {7 const browser = await chromium.launch();8 const context = await browser.newContext();9 const page = await context.newPage();10 await page.addInitScript({11 content: 'document.body.innerHTML = "<div id=\'test\'>Hello World</div>";'12 });13 const testDiv = await page.$('#test');14 expect(await testDiv.innerText()).toBe('Hello World');15 await browser.close();16})();17import React from 'react';18import { render } from '@testing-library/react';19import { chromium } from 'playwright';20import App from './App';21describe('App', () => {22 test('renders markup', async () => {23 const browser = await chromium.launch();24 const context = await browser.newContext();25 const page = await context.newPage();26 await page.addInitScript({

Full Screen

Using AI Code Generation

copy

Full Screen

1const playwright = require('playwright');2const { makeInsertMarkup } = require('playwright/internal/inspectorInstrumentation');3(async () => {4 const browser = await playwright.chromium.launch();5 const context = await browser.newContext();6 const page = await context.newPage();7 const table = await page.$('#customers');8 const row = await makeInsertMarkup('tr', [{ 'class': 'addedrow' }], [9 { 'td': 'New Row' },10 { 'td': 'New Row' },11 { 'td': 'New Row' }12 ]);13 await table.evaluate((table, row) => {14 table.insertAdjacentHTML('beforeend', row);15 }, row);16 await page.screenshot({ path: 'example.png' });17 await browser.close();18})();

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