MCPcopy Create free account
hub / github.com/microsoft/SandDance / SyntheticEvent

Function SyntheticEvent

docs/external/js/react-dom.development.js:8497–8544  ·  view source on GitHub ↗

* Synthetic events are dispatched by event plugins, typically in response to a * top-level event delegation handler. * * These systems should generally use pooling to reduce the frequency of garbage * collection. The system should check `isPersistent` to determine whether the * event

(dispatchConfig, targetInst, nativeEvent, nativeEventTarget)

Source from the content-addressed store, hash-verified

8495
8496
8497 function SyntheticEvent(dispatchConfig, targetInst, nativeEvent, nativeEventTarget) {
8498 {
8499 // these have a getter/setter for warnings
8500 delete this.nativeEvent;
8501 delete this.preventDefault;
8502 delete this.stopPropagation;
8503 delete this.isDefaultPrevented;
8504 delete this.isPropagationStopped;
8505 }
8506
8507 this.dispatchConfig = dispatchConfig;
8508 this._targetInst = targetInst;
8509 this.nativeEvent = nativeEvent;
8510 var Interface = this.constructor.Interface;
8511
8512 for (var propName in Interface) {
8513 if (!Interface.hasOwnProperty(propName)) {
8514 continue;
8515 }
8516
8517 {
8518 delete this[propName]; // this has a getter/setter for warnings
8519 }
8520
8521 var normalize = Interface[propName];
8522
8523 if (normalize) {
8524 this[propName] = normalize(nativeEvent);
8525 } else {
8526 if (propName === 'target') {
8527 this.target = nativeEventTarget;
8528 } else {
8529 this[propName] = nativeEvent[propName];
8530 }
8531 }
8532 }
8533
8534 var defaultPrevented = nativeEvent.defaultPrevented != null ? nativeEvent.defaultPrevented : nativeEvent.returnValue === false;
8535
8536 if (defaultPrevented) {
8537 this.isDefaultPrevented = functionThatReturnsTrue;
8538 } else {
8539 this.isDefaultPrevented = functionThatReturnsFalse;
8540 }
8541
8542 this.isPropagationStopped = functionThatReturnsFalse;
8543 return this;
8544 }
8545
8546 _assign(SyntheticEvent.prototype, {
8547 preventDefault: function () {

Callers

nothing calls this directly

Calls 1

normalizeFunction · 0.50

Tested by

no test coverage detected