MCPcopy Create free account
hub / github.com/krasimir/react-in-patterns / diffProperties$1

Function diffProperties$1

code/composition/public/app.js:16507–16669  ·  view source on GitHub ↗
(domElement, tag, lastRawProps, nextRawProps, rootContainerElement)

Source from the content-addressed store, hash-verified

16505
16506// Calculate the diff between the two objects.
16507function diffProperties$1(domElement, tag, lastRawProps, nextRawProps, rootContainerElement) {
16508 {
16509 validatePropertiesInDevelopment(tag, nextRawProps);
16510 }
16511
16512 var updatePayload = null;
16513
16514 var lastProps = void 0;
16515 var nextProps = void 0;
16516 switch (tag) {
16517 case 'input':
16518 lastProps = getHostProps(domElement, lastRawProps);
16519 nextProps = getHostProps(domElement, nextRawProps);
16520 updatePayload = [];
16521 break;
16522 case 'option':
16523 lastProps = getHostProps$1(domElement, lastRawProps);
16524 nextProps = getHostProps$1(domElement, nextRawProps);
16525 updatePayload = [];
16526 break;
16527 case 'select':
16528 lastProps = getHostProps$2(domElement, lastRawProps);
16529 nextProps = getHostProps$2(domElement, nextRawProps);
16530 updatePayload = [];
16531 break;
16532 case 'textarea':
16533 lastProps = getHostProps$3(domElement, lastRawProps);
16534 nextProps = getHostProps$3(domElement, nextRawProps);
16535 updatePayload = [];
16536 break;
16537 default:
16538 lastProps = lastRawProps;
16539 nextProps = nextRawProps;
16540 if (typeof lastProps.onClick !== 'function' && typeof nextProps.onClick === 'function') {
16541 // TODO: This cast may not be sound for SVG, MathML or custom elements.
16542 trapClickOnNonInteractiveElement(domElement);
16543 }
16544 break;
16545 }
16546
16547 assertValidProps(tag, nextProps, getStack);
16548
16549 var propKey = void 0;
16550 var styleName = void 0;
16551 var styleUpdates = null;
16552 for (propKey in lastProps) {
16553 if (nextProps.hasOwnProperty(propKey) || !lastProps.hasOwnProperty(propKey) || lastProps[propKey] == null) {
16554 continue;
16555 }
16556 if (propKey === STYLE) {
16557 var lastStyle = lastProps[propKey];
16558 for (styleName in lastStyle) {
16559 if (lastStyle.hasOwnProperty(styleName)) {
16560 if (!styleUpdates) {
16561 styleUpdates = {};
16562 }
16563 styleUpdates[styleName] = '';
16564 }

Callers

nothing calls this directly

Calls 7

getHostPropsFunction · 0.70
getHostProps$1Function · 0.70
getHostProps$2Function · 0.70
getHostProps$3Function · 0.70
assertValidPropsFunction · 0.70
ensureListeningToFunction · 0.70

Tested by

no test coverage detected