code
stringlengths
24
2.07M
docstring
stringlengths
25
85.3k
func_name
stringlengths
1
92
language
stringclasses
1 value
repo
stringlengths
5
64
path
stringlengths
4
172
url
stringlengths
44
218
license
stringclasses
7 values
function getSiblingNode(node: ?(Node | Element)) { while (node) { if (node.nextSibling) { return node.nextSibling; } node = node.parentNode; } }
Get the next sibling within a container. This will walk up the DOM if a node's siblings have been exhausted. @param {DOMElement|DOMTextNode} node @return {?DOMElement|DOMTextNode}
getSiblingNode
javascript
facebook/react
packages/react-dom-bindings/src/client/getNodeForCharacterOffset.js
https://github.com/facebook/react/blob/master/packages/react-dom-bindings/src/client/getNodeForCharacterOffset.js
MIT
function getNodeForCharacterOffset(root: Element, offset: number): ?Object { let node = getLeafNode(root); let nodeStart = 0; let nodeEnd = 0; while (node) { if (node.nodeType === TEXT_NODE) { nodeEnd = nodeStart + node.textContent.length; if (nodeStart <= offset && nodeEnd >= offset) { ...
Get object describing the nodes which contain characters at offset. @param {DOMElement|DOMTextNode} root @param {number} offset @return {?object}
getNodeForCharacterOffset
javascript
facebook/react
packages/react-dom-bindings/src/client/getNodeForCharacterOffset.js
https://github.com/facebook/react/blob/master/packages/react-dom-bindings/src/client/getNodeForCharacterOffset.js
MIT
if (enableScopeAPI) { return (scope: any)[internalInstanceKey] || null; }
Given a ReactDOMComponent or ReactDOMTextComponent, return the corresponding DOM node.
if
javascript
facebook/react
packages/react-dom-bindings/src/client/ReactDOMComponentTree.js
https://github.com/facebook/react/blob/master/packages/react-dom-bindings/src/client/ReactDOMComponentTree.js
MIT
function validateInputProps(element: Element, props: Object) { if (__DEV__) { // Normally we check for undefined and null the same, but explicitly specifying both // properties, at all is probably worth warning for. We could move this either direction // and just make it ok to pass null or just check hasO...
Implements an <input> host component that allows setting these optional props: `checked`, `value`, `defaultChecked`, and `defaultValue`. If `checked` or `value` are not supplied (or null/undefined), user actions that affect the checked state or value will trigger updates to the element. If they are supplied (and not ...
validateInputProps
javascript
facebook/react
packages/react-dom-bindings/src/client/ReactDOMInput.js
https://github.com/facebook/react/blob/master/packages/react-dom-bindings/src/client/ReactDOMInput.js
MIT
function updateInput( element: Element, value: ?string, defaultValue: ?string, lastDefaultValue: ?string, checked: ?boolean, defaultChecked: ?boolean, type: ?string, name: ?string, ) { const node: HTMLInputElement = (element: any); // Temporarily disconnect the input from any radio buttons. // Ch...
Implements an <input> host component that allows setting these optional props: `checked`, `value`, `defaultChecked`, and `defaultValue`. If `checked` or `value` are not supplied (or null/undefined), user actions that affect the checked state or value will trigger updates to the element. If they are supplied (and not ...
updateInput
javascript
facebook/react
packages/react-dom-bindings/src/client/ReactDOMInput.js
https://github.com/facebook/react/blob/master/packages/react-dom-bindings/src/client/ReactDOMInput.js
MIT
function initInput( element: Element, value: ?string, defaultValue: ?string, checked: ?boolean, defaultChecked: ?boolean, type: ?string, name: ?string, isHydrating: boolean, ) { const node: HTMLInputElement = (element: any); if ( type != null && typeof type !== 'function' && typeof type...
Implements an <input> host component that allows setting these optional props: `checked`, `value`, `defaultChecked`, and `defaultValue`. If `checked` or `value` are not supplied (or null/undefined), user actions that affect the checked state or value will trigger updates to the element. If they are supplied (and not ...
initInput
javascript
facebook/react
packages/react-dom-bindings/src/client/ReactDOMInput.js
https://github.com/facebook/react/blob/master/packages/react-dom-bindings/src/client/ReactDOMInput.js
MIT
function hydrateInput( element: Element, value: ?string, defaultValue: ?string, checked: ?boolean, defaultChecked: ?boolean, ): void { const node: HTMLInputElement = (element: any); const defaultValueStr = defaultValue != null ? toString(getToStringValue(defaultValue)) : ''; const initialValue = ...
Implements an <input> host component that allows setting these optional props: `checked`, `value`, `defaultChecked`, and `defaultValue`. If `checked` or `value` are not supplied (or null/undefined), user actions that affect the checked state or value will trigger updates to the element. If they are supplied (and not ...
hydrateInput
javascript
facebook/react
packages/react-dom-bindings/src/client/ReactDOMInput.js
https://github.com/facebook/react/blob/master/packages/react-dom-bindings/src/client/ReactDOMInput.js
MIT
function restoreControlledInputState(element: Element, props: Object) { const rootNode: HTMLInputElement = (element: any); updateInput( rootNode, props.value, props.defaultValue, props.defaultValue, props.checked, props.defaultChecked, props.type, props.name, ); const name = prop...
Implements an <input> host component that allows setting these optional props: `checked`, `value`, `defaultChecked`, and `defaultValue`. If `checked` or `value` are not supplied (or null/undefined), user actions that affect the checked state or value will trigger updates to the element. If they are supplied (and not ...
restoreControlledInputState
javascript
facebook/react
packages/react-dom-bindings/src/client/ReactDOMInput.js
https://github.com/facebook/react/blob/master/packages/react-dom-bindings/src/client/ReactDOMInput.js
MIT
function setDefaultValue( node: HTMLInputElement, type: ?string, value: ToStringValue, ) { if ( // Focused number inputs synchronize on blur. See ChangeEventPlugin.js type !== 'number' || getActiveElement(node.ownerDocument) !== node ) { if (node.defaultValue !== toString(value)) { node....
Implements an <input> host component that allows setting these optional props: `checked`, `value`, `defaultChecked`, and `defaultValue`. If `checked` or `value` are not supplied (or null/undefined), user actions that affect the checked state or value will trigger updates to the element. If they are supplied (and not ...
setDefaultValue
javascript
facebook/react
packages/react-dom-bindings/src/client/ReactDOMInput.js
https://github.com/facebook/react/blob/master/packages/react-dom-bindings/src/client/ReactDOMInput.js
MIT
function validateOptionProps(element: Element, props: Object) { if (__DEV__) { // If a value is not provided, then the children must be simple. if (props.value == null) { if (typeof props.children === 'object' && props.children !== null) { Children.forEach(props.children, function (child) { ...
Implements an <option> host component that warns when `selected` is set.
validateOptionProps
javascript
facebook/react
packages/react-dom-bindings/src/client/ReactDOMOption.js
https://github.com/facebook/react/blob/master/packages/react-dom-bindings/src/client/ReactDOMOption.js
MIT
function checkSelectPropTypes(props: any) { if (__DEV__) { for (let i = 0; i < valuePropNames.length; i++) { const propName = valuePropNames[i]; if (props[propName] == null) { continue; } const propNameIsArray = isArray(props[propName]); if (props.multiple && !propNameIsArray...
Validation function for `value` and `defaultValue`.
checkSelectPropTypes
javascript
facebook/react
packages/react-dom-bindings/src/client/ReactDOMSelect.js
https://github.com/facebook/react/blob/master/packages/react-dom-bindings/src/client/ReactDOMSelect.js
MIT
function updateOptions( node: HTMLSelectElement, multiple: boolean, propValue: any, setDefaultSelected: boolean, ) { const options: HTMLOptionsCollection = node.options; if (multiple) { const selectedValues = (propValue: Array<string>); const selectedValue: {[string]: boolean} = {}; for (let i ...
Validation function for `value` and `defaultValue`.
updateOptions
javascript
facebook/react
packages/react-dom-bindings/src/client/ReactDOMSelect.js
https://github.com/facebook/react/blob/master/packages/react-dom-bindings/src/client/ReactDOMSelect.js
MIT
function validateSelectProps(element: Element, props: Object) { if (__DEV__) { checkSelectPropTypes(props); if ( props.value !== undefined && props.defaultValue !== undefined && !didWarnValueDefaultValue ) { console.error( 'Select elements must be either controlled or uncon...
Implements a <select> host component that allows optionally setting the props `value` and `defaultValue`. If `multiple` is false, the prop must be a stringable. If `multiple` is true, the prop must be an array of stringables. If `value` is not supplied (or null/undefined), user actions that change the selected option ...
validateSelectProps
javascript
facebook/react
packages/react-dom-bindings/src/client/ReactDOMSelect.js
https://github.com/facebook/react/blob/master/packages/react-dom-bindings/src/client/ReactDOMSelect.js
MIT
function initSelect( element: Element, value: ?string, defaultValue: ?string, multiple: ?boolean, ) { const node: HTMLSelectElement = (element: any); node.multiple = !!multiple; if (value != null) { updateOptions(node, !!multiple, value, false); } else if (defaultValue != null) { updateOptions(n...
Implements a <select> host component that allows optionally setting the props `value` and `defaultValue`. If `multiple` is false, the prop must be a stringable. If `multiple` is true, the prop must be an array of stringables. If `value` is not supplied (or null/undefined), user actions that change the selected option ...
initSelect
javascript
facebook/react
packages/react-dom-bindings/src/client/ReactDOMSelect.js
https://github.com/facebook/react/blob/master/packages/react-dom-bindings/src/client/ReactDOMSelect.js
MIT
function hydrateSelect( element: Element, value: ?string, defaultValue: ?string, multiple: ?boolean, ): void { const node: HTMLSelectElement = (element: any); const options: HTMLOptionsCollection = node.options; const propValue: any = value != null ? value : defaultValue; let changed = false; if (m...
Implements a <select> host component that allows optionally setting the props `value` and `defaultValue`. If `multiple` is false, the prop must be a stringable. If `multiple` is true, the prop must be an array of stringables. If `value` is not supplied (or null/undefined), user actions that change the selected option ...
hydrateSelect
javascript
facebook/react
packages/react-dom-bindings/src/client/ReactDOMSelect.js
https://github.com/facebook/react/blob/master/packages/react-dom-bindings/src/client/ReactDOMSelect.js
MIT
function updateSelect( element: Element, value: ?string, defaultValue: ?string, multiple: ?boolean, wasMultiple: ?boolean, ) { const node: HTMLSelectElement = (element: any); if (value != null) { updateOptions(node, !!multiple, value, false); } else if (!!wasMultiple !== !!multiple) { // For si...
Implements a <select> host component that allows optionally setting the props `value` and `defaultValue`. If `multiple` is false, the prop must be a stringable. If `multiple` is true, the prop must be an array of stringables. If `value` is not supplied (or null/undefined), user actions that change the selected option ...
updateSelect
javascript
facebook/react
packages/react-dom-bindings/src/client/ReactDOMSelect.js
https://github.com/facebook/react/blob/master/packages/react-dom-bindings/src/client/ReactDOMSelect.js
MIT
function restoreControlledSelectState(element: Element, props: Object) { const node: HTMLSelectElement = (element: any); const value = props.value; if (value != null) { updateOptions(node, !!props.multiple, value, false); } }
Implements a <select> host component that allows optionally setting the props `value` and `defaultValue`. If `multiple` is false, the prop must be a stringable. If `multiple` is true, the prop must be an array of stringables. If `value` is not supplied (or null/undefined), user actions that change the selected option ...
restoreControlledSelectState
javascript
facebook/react
packages/react-dom-bindings/src/client/ReactDOMSelect.js
https://github.com/facebook/react/blob/master/packages/react-dom-bindings/src/client/ReactDOMSelect.js
MIT
function getModernOffsetsFromPoints( outerNode, anchorNode, anchorOffset, focusNode, focusOffset, ) { let length = 0; let start = -1; let end = -1; let indexWithinAnchor = 0; let indexWithinFocus = 0; let node = outerNode; let parentNode = null; outer: while (true) { let next = null; ...
Returns {start, end} where `start` is the character/codepoint index of (anchorNode, anchorOffset) within the textContent of `outerNode`, and `end` is the index of (focusNode, focusOffset). Returns null if you pass in garbage input but we should probably just crash. Exported only for testing.
getModernOffsetsFromPoints
javascript
facebook/react
packages/react-dom-bindings/src/client/ReactDOMSelection.js
https://github.com/facebook/react/blob/master/packages/react-dom-bindings/src/client/ReactDOMSelection.js
MIT
function setOffsets(node, offsets) { const doc = node.ownerDocument || document; const win = (doc && doc.defaultView) || window; // Edge fails with "Object expected" in some scenarios. // (For instance: TinyMCE editor used in a list component that supports pasting to add more, // fails when pasting 100+ item...
In modern non-IE browsers, we can support both forward and backward selections. Note: IE10+ supports the Selection object, but it does not support the `extend` method, which means that even in modern IE, it's not possible to programmatically create a backward selection. Thus, for all IE versions, we use the old IE API...
setOffsets
javascript
facebook/react
packages/react-dom-bindings/src/client/ReactDOMSelection.js
https://github.com/facebook/react/blob/master/packages/react-dom-bindings/src/client/ReactDOMSelection.js
MIT
function validateTextareaProps(element: Element, props: Object) { if (__DEV__) { if ( props.value !== undefined && props.defaultValue !== undefined && !didWarnValDefaultVal ) { console.error( '%s contains a textarea with both value and defaultValue props. ' + 'Textare...
Implements a <textarea> host component that allows setting `value`, and `defaultValue`. This differs from the traditional DOM API because value is usually set as PCDATA children. If `value` is not supplied (or null/undefined), user actions that affect the value will trigger updates to the element. If `value` is suppl...
validateTextareaProps
javascript
facebook/react
packages/react-dom-bindings/src/client/ReactDOMTextarea.js
https://github.com/facebook/react/blob/master/packages/react-dom-bindings/src/client/ReactDOMTextarea.js
MIT
function updateTextarea( element: Element, value: ?string, defaultValue: ?string, ) { const node: HTMLTextAreaElement = (element: any); if (value != null) { // Cast `value` to a string to ensure the value is set correctly. While // browsers typically do this as necessary, jsdom doesn't. const newV...
Implements a <textarea> host component that allows setting `value`, and `defaultValue`. This differs from the traditional DOM API because value is usually set as PCDATA children. If `value` is not supplied (or null/undefined), user actions that affect the value will trigger updates to the element. If `value` is suppl...
updateTextarea
javascript
facebook/react
packages/react-dom-bindings/src/client/ReactDOMTextarea.js
https://github.com/facebook/react/blob/master/packages/react-dom-bindings/src/client/ReactDOMTextarea.js
MIT
function initTextarea( element: Element, value: ?string, defaultValue: ?string, children: ?string, ) { const node: HTMLTextAreaElement = (element: any); let initialValue = value; // Only bother fetching default value if we're going to use it if (initialValue == null) { if (children != null) { ...
Implements a <textarea> host component that allows setting `value`, and `defaultValue`. This differs from the traditional DOM API because value is usually set as PCDATA children. If `value` is not supplied (or null/undefined), user actions that affect the value will trigger updates to the element. If `value` is suppl...
initTextarea
javascript
facebook/react
packages/react-dom-bindings/src/client/ReactDOMTextarea.js
https://github.com/facebook/react/blob/master/packages/react-dom-bindings/src/client/ReactDOMTextarea.js
MIT
function hydrateTextarea( element: Element, value: ?string, defaultValue: ?string, ): void { const node: HTMLTextAreaElement = (element: any); let initialValue = value; if (initialValue == null) { if (defaultValue == null) { defaultValue = ''; } initialValue = defaultValue; } // Track ...
Implements a <textarea> host component that allows setting `value`, and `defaultValue`. This differs from the traditional DOM API because value is usually set as PCDATA children. If `value` is not supplied (or null/undefined), user actions that affect the value will trigger updates to the element. If `value` is suppl...
hydrateTextarea
javascript
facebook/react
packages/react-dom-bindings/src/client/ReactDOMTextarea.js
https://github.com/facebook/react/blob/master/packages/react-dom-bindings/src/client/ReactDOMTextarea.js
MIT
function restoreControlledTextareaState( element: Element, props: Object, ) { // DOM component is still mounted; update updateTextarea(element, props.value, props.defaultValue); }
Implements a <textarea> host component that allows setting `value`, and `defaultValue`. This differs from the traditional DOM API because value is usually set as PCDATA children. If `value` is not supplied (or null/undefined), user actions that affect the value will trigger updates to the element. If `value` is suppl...
restoreControlledTextareaState
javascript
facebook/react
packages/react-dom-bindings/src/client/ReactDOMTextarea.js
https://github.com/facebook/react/blob/master/packages/react-dom-bindings/src/client/ReactDOMTextarea.js
MIT
function hasSelectionCapabilities(elem) { const nodeName = elem && elem.nodeName && elem.nodeName.toLowerCase(); return ( nodeName && ((nodeName === 'input' && (elem.type === 'text' || elem.type === 'search' || elem.type === 'tel' || elem.type === 'url' || elem.type ===...
@hasSelectionCapabilities: we get the element types that support selection from https://html.spec.whatwg.org/#do-not-apply, looking at `selectionStart` and `selectionEnd` rows.
hasSelectionCapabilities
javascript
facebook/react
packages/react-dom-bindings/src/client/ReactInputSelection.js
https://github.com/facebook/react/blob/master/packages/react-dom-bindings/src/client/ReactInputSelection.js
MIT
function getSelectionInformation(containerInfo) { const focusedElem = getActiveElementDeep(containerInfo); return { focusedElem: focusedElem, selectionRange: hasSelectionCapabilities(focusedElem) ? getSelection(focusedElem) : null, }; }
@hasSelectionCapabilities: we get the element types that support selection from https://html.spec.whatwg.org/#do-not-apply, looking at `selectionStart` and `selectionEnd` rows.
getSelectionInformation
javascript
facebook/react
packages/react-dom-bindings/src/client/ReactInputSelection.js
https://github.com/facebook/react/blob/master/packages/react-dom-bindings/src/client/ReactInputSelection.js
MIT
function restoreSelection(priorSelectionInformation, containerInfo) { const curFocusedElem = getActiveElementDeep(containerInfo); const priorFocusedElem = priorSelectionInformation.focusedElem; const priorSelectionRange = priorSelectionInformation.selectionRange; if (curFocusedElem !== priorFocusedElem && isInD...
@restoreSelection: If any selection information was potentially lost, restore it. This is useful when performing operations that could remove dom nodes and place them back in, resulting in focus being lost.
restoreSelection
javascript
facebook/react
packages/react-dom-bindings/src/client/ReactInputSelection.js
https://github.com/facebook/react/blob/master/packages/react-dom-bindings/src/client/ReactInputSelection.js
MIT
function getSelection(input) { let selection; if ('selectionStart' in input) { // Modern browser with input or textarea. selection = { start: input.selectionStart, end: input.selectionEnd, }; } else { // Content editable or old IE textarea. selection = getOffsets(input); } re...
@getSelection: Gets the selection bounds of a focused textarea, input or contentEditable node. -@input: Look up selection bounds of this input -@return {start: selectionStart, end: selectionEnd}
getSelection
javascript
facebook/react
packages/react-dom-bindings/src/client/ReactInputSelection.js
https://github.com/facebook/react/blob/master/packages/react-dom-bindings/src/client/ReactInputSelection.js
MIT
function setSelection(input, offsets) { const start = offsets.start; let end = offsets.end; if (end === undefined) { end = start; } if ('selectionStart' in input) { input.selectionStart = start; input.selectionEnd = Math.min(end, input.value.length); } else { setOffsets(input, offsets); }...
@setSelection: Sets the selection bounds of a textarea or input and focuses the input. -@input Set selection bounds of this input or textarea -@offsets Object of same form that is returned from get*
setSelection
javascript
facebook/react
packages/react-dom-bindings/src/client/ReactInputSelection.js
https://github.com/facebook/react/blob/master/packages/react-dom-bindings/src/client/ReactInputSelection.js
MIT
function setTextContent(node: Element, text: string): void { if (text) { const firstChild = node.firstChild; if ( firstChild && firstChild === node.lastChild && firstChild.nodeType === TEXT_NODE ) { firstChild.nodeValue = text; return; } } node.textContent = text; }
Set the textContent property of a node. For text updates, it's faster to set the `nodeValue` of the Text node directly instead of using `.textContent` which will remove the existing node and create a new one. @param {DOMElement} node @param {string} text @internal
setTextContent
javascript
facebook/react
packages/react-dom-bindings/src/client/setTextContent.js
https://github.com/facebook/react/blob/master/packages/react-dom-bindings/src/client/setTextContent.js
MIT
function registerTwoPhaseEvent( registrationName: string, dependencies: Array<DOMEventName>, ): void { registerDirectEvent(registrationName, dependencies); registerDirectEvent(registrationName + 'Capture', dependencies); }
Mapping from lowercase registration names to the properly cased version, used to warn in the case of missing event handlers. Available only in __DEV__. @type {Object}
registerTwoPhaseEvent
javascript
facebook/react
packages/react-dom-bindings/src/events/EventRegistry.js
https://github.com/facebook/react/blob/master/packages/react-dom-bindings/src/events/EventRegistry.js
MIT
function registerDirectEvent( registrationName: string, dependencies: Array<DOMEventName>, ) { if (__DEV__) { if (registrationNameDependencies[registrationName]) { console.error( 'EventRegistry: More than one plugin attempted to publish the same ' + 'registration name, `%s`.', ...
Mapping from lowercase registration names to the properly cased version, used to warn in the case of missing event handlers. Available only in __DEV__. @type {Object}
registerDirectEvent
javascript
facebook/react
packages/react-dom-bindings/src/events/EventRegistry.js
https://github.com/facebook/react/blob/master/packages/react-dom-bindings/src/events/EventRegistry.js
MIT
function initialize(nativeEventTarget) { root = nativeEventTarget; startText = getText(); return true; }
These variables store information about text content of a target node, allowing comparison of content before and after a given event. Identify the node where selection currently begins, then observe both its text content and its current position in the DOM. Since the browser may natively replace the target node during...
initialize
javascript
facebook/react
packages/react-dom-bindings/src/events/FallbackCompositionState.js
https://github.com/facebook/react/blob/master/packages/react-dom-bindings/src/events/FallbackCompositionState.js
MIT
function reset() { root = null; startText = null; fallbackText = null; }
These variables store information about text content of a target node, allowing comparison of content before and after a given event. Identify the node where selection currently begins, then observe both its text content and its current position in the DOM. Since the browser may natively replace the target node during...
reset
javascript
facebook/react
packages/react-dom-bindings/src/events/FallbackCompositionState.js
https://github.com/facebook/react/blob/master/packages/react-dom-bindings/src/events/FallbackCompositionState.js
MIT
function getData() { if (fallbackText) { return fallbackText; } let start; const startValue = startText; const startLength = startValue.length; let end; const endValue = getText(); const endLength = endValue.length; for (start = 0; start < startLength; start++) { if (startValue[start] !== en...
These variables store information about text content of a target node, allowing comparison of content before and after a given event. Identify the node where selection currently begins, then observe both its text content and its current position in the DOM. Since the browser may natively replace the target node during...
getData
javascript
facebook/react
packages/react-dom-bindings/src/events/FallbackCompositionState.js
https://github.com/facebook/react/blob/master/packages/react-dom-bindings/src/events/FallbackCompositionState.js
MIT
function getText() { if ('value' in root) { return root.value; } return root.textContent; }
These variables store information about text content of a target node, allowing comparison of content before and after a given event. Identify the node where selection currently begins, then observe both its text content and its current position in the DOM. Since the browser may natively replace the target node during...
getText
javascript
facebook/react
packages/react-dom-bindings/src/events/FallbackCompositionState.js
https://github.com/facebook/react/blob/master/packages/react-dom-bindings/src/events/FallbackCompositionState.js
MIT
function getEventCharCode(nativeEvent: KeyboardEvent): number { let charCode; const keyCode = nativeEvent.keyCode; if ('charCode' in nativeEvent) { charCode = nativeEvent.charCode; // FF does not set `charCode` for the Enter-key, check against `keyCode`. if (charCode === 0 && keyCode === 13) { ...
`charCode` represents the actual "character code" and is safe to use with `String.fromCharCode`. As such, only keys that correspond to printable characters produce a valid `charCode`, the only exception to this is Enter. The Tab-key is considered non-printable and does not have a `charCode`, presumably because it does ...
getEventCharCode
javascript
facebook/react
packages/react-dom-bindings/src/events/getEventCharCode.js
https://github.com/facebook/react/blob/master/packages/react-dom-bindings/src/events/getEventCharCode.js
MIT
function getEventTarget(nativeEvent) { // Fallback to nativeEvent.srcElement for IE9 // https://github.com/facebook/react/issues/12506 let target = nativeEvent.target || nativeEvent.srcElement || window; // Normalize SVG <use> element events #4963 if (target.correspondingUseElement) { target = target.cor...
Gets the target node from a native browser event by accounting for inconsistencies in browser DOM APIs. @param {object} nativeEvent Native browser event. @return {DOMEventTarget} Target node.
getEventTarget
javascript
facebook/react
packages/react-dom-bindings/src/events/getEventTarget.js
https://github.com/facebook/react/blob/master/packages/react-dom-bindings/src/events/getEventTarget.js
MIT
function getListener( inst: Fiber, registrationName: string, ): Function | null { const stateNode = inst.stateNode; if (stateNode === null) { // Work in progress (ex: onload events in incremental mode). return null; } const props = getFiberCurrentPropsFromNode(stateNode); if (props === null) { ...
@param {object} inst The instance, which is the source of events. @param {string} registrationName Name of listener (e.g. `onClick`). @return {?function} The stored callback.
getListener
javascript
facebook/react
packages/react-dom-bindings/src/events/getListener.js
https://github.com/facebook/react/blob/master/packages/react-dom-bindings/src/events/getListener.js
MIT
function makePrefixMap(styleProp, eventName) { const prefixes = {}; prefixes[styleProp.toLowerCase()] = eventName.toLowerCase(); prefixes['Webkit' + styleProp] = 'webkit' + eventName; prefixes['Moz' + styleProp] = 'moz' + eventName; return prefixes; }
Generate a mapping of standard vendor prefixes using the defined style property and event name. @param {string} styleProp @param {string} eventName @returns {object}
makePrefixMap
javascript
facebook/react
packages/react-dom-bindings/src/events/getVendorPrefixedEventName.js
https://github.com/facebook/react/blob/master/packages/react-dom-bindings/src/events/getVendorPrefixedEventName.js
MIT
function getVendorPrefixedEventName(eventName) { if (prefixedEventNames[eventName]) { return prefixedEventNames[eventName]; } else if (!vendorPrefixes[eventName]) { return eventName; } const prefixMap = vendorPrefixes[eventName]; for (const styleProp in prefixMap) { if (prefixMap.hasOwnProperty(...
Attempts to determine the correct vendor prefixed event name. @param {string} eventName @returns {string}
getVendorPrefixedEventName
javascript
facebook/react
packages/react-dom-bindings/src/events/getVendorPrefixedEventName.js
https://github.com/facebook/react/blob/master/packages/react-dom-bindings/src/events/getVendorPrefixedEventName.js
MIT
function SyntheticBaseEvent( reactName: string | null, reactEventType: string, targetInst: Fiber | null, nativeEvent: {[propName: string]: mixed, ...}, nativeEventTarget: null | EventTarget, ) { this._reactName = reactName; this._targetInst = targetInst; this.type = reactEventType; ...
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 should be released into the pool after being d...
SyntheticBaseEvent
javascript
facebook/react
packages/react-dom-bindings/src/events/SyntheticEvent.js
https://github.com/facebook/react/blob/master/packages/react-dom-bindings/src/events/SyntheticEvent.js
MIT
function updateMouseMovementPolyfillState(event: {[propName: string]: mixed}) { if (event !== lastMouseEvent) { if (lastMouseEvent && event.type === 'mousemove') { // $FlowFixMe[unsafe-arithmetic] assuming this is a number lastMovementX = event.screenX - lastMouseEvent.screenX; // $FlowFixMe[uns...
@interface Event @see http://www.w3.org/TR/DOM-Level-3-Events/
updateMouseMovementPolyfillState
javascript
facebook/react
packages/react-dom-bindings/src/events/SyntheticEvent.js
https://github.com/facebook/react/blob/master/packages/react-dom-bindings/src/events/SyntheticEvent.js
MIT
function getEventKey(nativeEvent: {[propName: string]: mixed}) { if (nativeEvent.key) { // Normalize inconsistent values reported by browsers due to // implementations of a working draft specification. // FireFox implements `key` but returns `MozPrintableKey` for all // printable characters (normaliz...
@param {object} nativeEvent Native browser event. @return {string} Normalized `key` property.
getEventKey
javascript
facebook/react
packages/react-dom-bindings/src/events/SyntheticEvent.js
https://github.com/facebook/react/blob/master/packages/react-dom-bindings/src/events/SyntheticEvent.js
MIT
function modifierStateGetter(keyArg) { const syntheticEvent = this; const nativeEvent = syntheticEvent.nativeEvent; if (nativeEvent.getModifierState) { return nativeEvent.getModifierState(keyArg); } const keyProp = modifierKeyToProp[keyArg]; return keyProp ? !!nativeEvent[keyProp] : false; }
Translation from modifier key to the associated property in the event. @see http://www.w3.org/TR/DOM-Level-3-Events/#keys-Modifiers
modifierStateGetter
javascript
facebook/react
packages/react-dom-bindings/src/events/SyntheticEvent.js
https://github.com/facebook/react/blob/master/packages/react-dom-bindings/src/events/SyntheticEvent.js
MIT
function getEventModifierState(nativeEvent: {[propName: string]: mixed}) { return modifierStateGetter; }
Translation from modifier key to the associated property in the event. @see http://www.w3.org/TR/DOM-Level-3-Events/#keys-Modifiers
getEventModifierState
javascript
facebook/react
packages/react-dom-bindings/src/events/SyntheticEvent.js
https://github.com/facebook/react/blob/master/packages/react-dom-bindings/src/events/SyntheticEvent.js
MIT
function isKeypressCommand(nativeEvent: any) { return ( (nativeEvent.ctrlKey || nativeEvent.altKey || nativeEvent.metaKey) && // ctrlKey && altKey is equivalent to AltGr, and is not a command. !(nativeEvent.ctrlKey && nativeEvent.altKey) ); }
Return whether a native keypress event is assumed to be a command. This is required because Firefox fires `keypress` events for key commands (cut, copy, select-all, etc.) even though no character is inserted.
isKeypressCommand
javascript
facebook/react
packages/react-dom-bindings/src/events/plugins/BeforeInputEventPlugin.js
https://github.com/facebook/react/blob/master/packages/react-dom-bindings/src/events/plugins/BeforeInputEventPlugin.js
MIT
function getCompositionEventType(domEventName: DOMEventName) { switch (domEventName) { case 'compositionstart': return 'onCompositionStart'; case 'compositionend': return 'onCompositionEnd'; case 'compositionupdate': return 'onCompositionUpdate'; } }
Translate native top level events into event types.
getCompositionEventType
javascript
facebook/react
packages/react-dom-bindings/src/events/plugins/BeforeInputEventPlugin.js
https://github.com/facebook/react/blob/master/packages/react-dom-bindings/src/events/plugins/BeforeInputEventPlugin.js
MIT
function isFallbackCompositionStart( domEventName: DOMEventName, nativeEvent: any, ): boolean { return domEventName === 'keydown' && nativeEvent.keyCode === START_KEYCODE; }
Does our fallback best-guess model think this event signifies that composition has begun?
isFallbackCompositionStart
javascript
facebook/react
packages/react-dom-bindings/src/events/plugins/BeforeInputEventPlugin.js
https://github.com/facebook/react/blob/master/packages/react-dom-bindings/src/events/plugins/BeforeInputEventPlugin.js
MIT
function isFallbackCompositionEnd( domEventName: DOMEventName, nativeEvent: any, ): boolean { switch (domEventName) { case 'keyup': // Command keys insert or clear IME input. return END_KEYCODES.indexOf(nativeEvent.keyCode) !== -1; case 'keydown': // Expect IME keyCode on each keydown. I...
Does our fallback mode think that this event is the end of composition?
isFallbackCompositionEnd
javascript
facebook/react
packages/react-dom-bindings/src/events/plugins/BeforeInputEventPlugin.js
https://github.com/facebook/react/blob/master/packages/react-dom-bindings/src/events/plugins/BeforeInputEventPlugin.js
MIT
function getDataFromCustomEvent(nativeEvent: any) { const detail = nativeEvent.detail; if (typeof detail === 'object' && 'data' in detail) { return detail.data; } return null; }
Google Input Tools provides composition data via a CustomEvent, with the `data` property populated in the `detail` object. If this is available on the event object, use it. If not, this is a plain composition event and we have nothing special to extract. @param {object} nativeEvent @return {?string}
getDataFromCustomEvent
javascript
facebook/react
packages/react-dom-bindings/src/events/plugins/BeforeInputEventPlugin.js
https://github.com/facebook/react/blob/master/packages/react-dom-bindings/src/events/plugins/BeforeInputEventPlugin.js
MIT
function isUsingKoreanIME(nativeEvent: any) { return nativeEvent.locale === 'ko'; }
Check if a composition event was triggered by Korean IME. Our fallback mode does not work well with IE's Korean IME, so just use native composition events when Korean IME is used. Although CompositionEvent.locale property is deprecated, it is available in IE, where our fallback mode is enabled. @param {object} nativeE...
isUsingKoreanIME
javascript
facebook/react
packages/react-dom-bindings/src/events/plugins/BeforeInputEventPlugin.js
https://github.com/facebook/react/blob/master/packages/react-dom-bindings/src/events/plugins/BeforeInputEventPlugin.js
MIT
function getFallbackBeforeInputChars( domEventName: DOMEventName, nativeEvent: any, ): ?string { // If we are currently composing (IME) and using a fallback to do so, // try to extract the composed characters from the fallback object. // If composition event is available, we extract a string only at // comp...
For browsers that do not provide the `textInput` event, extract the appropriate string to use for SyntheticInputEvent.
getFallbackBeforeInputChars
javascript
facebook/react
packages/react-dom-bindings/src/events/plugins/BeforeInputEventPlugin.js
https://github.com/facebook/react/blob/master/packages/react-dom-bindings/src/events/plugins/BeforeInputEventPlugin.js
MIT
function extractBeforeInputEvent( dispatchQueue: DispatchQueue, domEventName: DOMEventName, targetInst: null | Fiber, nativeEvent: AnyNativeEvent, nativeEventTarget: null | EventTarget, ) { let chars; if (canUseTextInputEvent) { chars = getNativeBeforeInputChars(domEventName, nativeEvent); } else {...
Extract a SyntheticInputEvent for `beforeInput`, based on either native `textInput` or fallback behavior. @return {?object} A SyntheticInputEvent.
extractBeforeInputEvent
javascript
facebook/react
packages/react-dom-bindings/src/events/plugins/BeforeInputEventPlugin.js
https://github.com/facebook/react/blob/master/packages/react-dom-bindings/src/events/plugins/BeforeInputEventPlugin.js
MIT
function extractEvents( dispatchQueue: DispatchQueue, domEventName: DOMEventName, targetInst: null | Fiber, nativeEvent: AnyNativeEvent, nativeEventTarget: null | EventTarget, eventSystemFlags: EventSystemFlags, targetContainer: EventTarget, ) { const isOverEvent = domEventName === 'mouseover' || do...
For almost every interaction we care about, there will be both a top-level `mouseover` and `mouseout` event that occurs. Only use `mouseout` so that we do not extract duplicate events. However, moving the mouse into the browser from outside will not fire a `mouseout` event. In this case, we use the `mouseover` top-leve...
extractEvents
javascript
facebook/react
packages/react-dom-bindings/src/events/plugins/EnterLeaveEventPlugin.js
https://github.com/facebook/react/blob/master/packages/react-dom-bindings/src/events/plugins/EnterLeaveEventPlugin.js
MIT
function extractEvents( dispatchQueue: DispatchQueue, domEventName: DOMEventName, targetInst: null | Fiber, nativeEvent: AnyNativeEvent, nativeEventTarget: null | EventTarget, eventSystemFlags: EventSystemFlags, targetContainer: null | EventTarget, ) { if (!enableScrollEndPolyfill) { return; } ...
This plugin creates an `onScrollEnd` event polyfill when the native one is not available.
extractEvents
javascript
facebook/react
packages/react-dom-bindings/src/events/plugins/ScrollEndEventPlugin.js
https://github.com/facebook/react/blob/master/packages/react-dom-bindings/src/events/plugins/ScrollEndEventPlugin.js
MIT
function getSelection(node: any) { if ('selectionStart' in node && hasSelectionCapabilities(node)) { return { start: node.selectionStart, end: node.selectionEnd, }; } else { const win = (node.ownerDocument && node.ownerDocument.defaultView) || window; const selection = win.getSelec...
Get an object which is a unique representation of the current selection. The return value will not be consistent across nodes or browsers, but two identical selections on the same node will return identical objects.
getSelection
javascript
facebook/react
packages/react-dom-bindings/src/events/plugins/SelectEventPlugin.js
https://github.com/facebook/react/blob/master/packages/react-dom-bindings/src/events/plugins/SelectEventPlugin.js
MIT
function getEventTargetDocument(eventTarget: any) { return eventTarget.window === eventTarget ? eventTarget.document : eventTarget.nodeType === DOCUMENT_NODE ? eventTarget : eventTarget.ownerDocument; }
Get document associated with the event target.
getEventTargetDocument
javascript
facebook/react
packages/react-dom-bindings/src/events/plugins/SelectEventPlugin.js
https://github.com/facebook/react/blob/master/packages/react-dom-bindings/src/events/plugins/SelectEventPlugin.js
MIT
function constructSelectEvent( dispatchQueue: DispatchQueue, nativeEvent: AnyNativeEvent, nativeEventTarget: null | EventTarget, ) { // Ensure we have the right element, and that the user is not dragging a // selection (this matches native `select` event behavior). In HTML5, select // fires only on input an...
Poll selection to see whether it's changed. @param {object} nativeEvent @param {object} nativeEventTarget @return {?SyntheticEvent}
constructSelectEvent
javascript
facebook/react
packages/react-dom-bindings/src/events/plugins/SelectEventPlugin.js
https://github.com/facebook/react/blob/master/packages/react-dom-bindings/src/events/plugins/SelectEventPlugin.js
MIT
function extractEvents( dispatchQueue: DispatchQueue, domEventName: DOMEventName, targetInst: null | Fiber, nativeEvent: AnyNativeEvent, nativeEventTarget: null | EventTarget, eventSystemFlags: EventSystemFlags, targetContainer: EventTarget, ) { const targetNode = targetInst ? getNodeFromInstance(target...
This plugin creates an `onSelect` event that normalizes select events across form elements. Supported elements are: - input (see `isTextInputElement`) - textarea - contentEditable This differs from native browser implementations in the following ways: - Fires on contentEditable fields as well as inputs. - Fires for c...
extractEvents
javascript
facebook/react
packages/react-dom-bindings/src/events/plugins/SelectEventPlugin.js
https://github.com/facebook/react/blob/master/packages/react-dom-bindings/src/events/plugins/SelectEventPlugin.js
MIT
function escapeHtml(string: string) { if (__DEV__) { checkHtmlStringCoercion(string); } const str = '' + string; const match = matchHtmlRegExp.exec(str); if (!match) { return str; } let escape; let html = ''; let index; let lastIndex = 0; for (index = match.index; index < str.length; in...
Escapes special characters and HTML entities in a given html string. @param {string} string HTML string to escape for later insertion @return {string} @public
escapeHtml
javascript
facebook/react
packages/react-dom-bindings/src/server/escapeTextForBrowser.js
https://github.com/facebook/react/blob/master/packages/react-dom-bindings/src/server/escapeTextForBrowser.js
MIT
function handleExistingNodes(target: HTMLElement) { const existingNodes = target.querySelectorAll('template'); for (let i = 0; i < existingNodes.length; i++) { handleNode(existingNodes[i]); } }
This file is compiled to a standalone browser script by rollup and loaded by Fizz clients. Therefore, it should be fast and not have many external dependencies. @flow
handleExistingNodes
javascript
facebook/react
packages/react-dom-bindings/src/server/ReactDOMServerExternalRuntime.js
https://github.com/facebook/react/blob/master/packages/react-dom-bindings/src/server/ReactDOMServerExternalRuntime.js
MIT
function installFizzInstrObserver(target: Node) { const handleMutations = (mutations: Array<MutationRecord>) => { for (let i = 0; i < mutations.length; i++) { const addedNodes = mutations[i].addedNodes; for (let j = 0; j < addedNodes.length; j++) { if (addedNodes[j].parentNode) { han...
This file is compiled to a standalone browser script by rollup and loaded by Fizz clients. Therefore, it should be fast and not have many external dependencies. @flow
installFizzInstrObserver
javascript
facebook/react
packages/react-dom-bindings/src/server/ReactDOMServerExternalRuntime.js
https://github.com/facebook/react/blob/master/packages/react-dom-bindings/src/server/ReactDOMServerExternalRuntime.js
MIT
handleMutations = (mutations: Array<MutationRecord>) => { for (let i = 0; i < mutations.length; i++) { const addedNodes = mutations[i].addedNodes; for (let j = 0; j < addedNodes.length; j++) { if (addedNodes[j].parentNode) { handleNode(addedNodes[j]); } } } }
This file is compiled to a standalone browser script by rollup and loaded by Fizz clients. Therefore, it should be fast and not have many external dependencies. @flow
handleMutations
javascript
facebook/react
packages/react-dom-bindings/src/server/ReactDOMServerExternalRuntime.js
https://github.com/facebook/react/blob/master/packages/react-dom-bindings/src/server/ReactDOMServerExternalRuntime.js
MIT
handleMutations = (mutations: Array<MutationRecord>) => { for (let i = 0; i < mutations.length; i++) { const addedNodes = mutations[i].addedNodes; for (let j = 0; j < addedNodes.length; j++) { if (addedNodes[j].parentNode) { handleNode(addedNodes[j]); } } } }
This file is compiled to a standalone browser script by rollup and loaded by Fizz clients. Therefore, it should be fast and not have many external dependencies. @flow
handleMutations
javascript
facebook/react
packages/react-dom-bindings/src/server/ReactDOMServerExternalRuntime.js
https://github.com/facebook/react/blob/master/packages/react-dom-bindings/src/server/ReactDOMServerExternalRuntime.js
MIT
function handleNode(node_: Node) { // $FlowFixMe[incompatible-cast] if (node_.nodeType !== 1 || !(node_: HTMLElement).dataset) { return; } // $FlowFixMe[incompatible-cast] const node = (node_: HTMLElement); const dataset = node.dataset; if (dataset['rxi'] != null) { window['$RX']( dataset['b...
This file is compiled to a standalone browser script by rollup and loaded by Fizz clients. Therefore, it should be fast and not have many external dependencies. @flow
handleNode
javascript
facebook/react
packages/react-dom-bindings/src/server/ReactDOMServerExternalRuntime.js
https://github.com/facebook/react/blob/master/packages/react-dom-bindings/src/server/ReactDOMServerExternalRuntime.js
MIT
function escapeEntireInlineScriptContent(scriptText: string) { if (__DEV__) { checkHtmlStringCoercion(scriptText); } return ('' + scriptText).replace(scriptRegex, scriptReplacer); }
This escaping function is designed to work with with inline scripts where the entire contents are escaped. Because we know we are escaping the entire script we can avoid for instance escaping html comment string sequences that are valid javascript as well because if there are no sebsequent <script sequences the html pa...
escapeEntireInlineScriptContent
javascript
facebook/react
packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js
https://github.com/facebook/react/blob/master/packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js
MIT
scriptReplacer = ( match: string, prefix: string, s: string, suffix: string, ) => `${prefix}${s === 's' ? '\\u0073' : '\\u0053'}${suffix}`
This escaping function is designed to work with with inline scripts where the entire contents are escaped. Because we know we are escaping the entire script we can avoid for instance escaping html comment string sequences that are valid javascript as well because if there are no sebsequent <script sequences the html pa...
scriptReplacer
javascript
facebook/react
packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js
https://github.com/facebook/react/blob/master/packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js
MIT
scriptReplacer = ( match: string, prefix: string, s: string, suffix: string, ) => `${prefix}${s === 's' ? '\\u0073' : '\\u0053'}${suffix}`
This escaping function is designed to work with with inline scripts where the entire contents are escaped. Because we know we are escaping the entire script we can avoid for instance escaping html comment string sequences that are valid javascript as well because if there are no sebsequent <script sequences the html pa...
scriptReplacer
javascript
facebook/react
packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js
https://github.com/facebook/react/blob/master/packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js
MIT
if (onHeaders && typeof maxHeadersLength === 'number') { if (maxHeadersLength <= 0) { console.error( 'React expected a positive non-zero `maxHeadersLength` option but found %s instead. When using the `onHeaders` option you may supply an optional `maxHeadersLength` option as well however, when se...
This escaping function is designed to work with with inline scripts where the entire contents are escaped. Because we know we are escaping the entire script we can avoid for instance escaping html comment string sequences that are valid javascript as well because if there are no sebsequent <script sequences the html pa...
if
javascript
facebook/react
packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js
https://github.com/facebook/react/blob/master/packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js
MIT
if (typeof style !== 'object') { throw new Error( 'The `style` prop expects a mapping from style properties to values, ' + "not a string. For example, style={{marginRight: spacing + 'em'}} when " + 'using JSX.', ); }
This escaping function is designed to work with with inline scripts where the entire contents are escaped. Because we know we are escaping the entire script we can avoid for instance escaping html comment string sequences that are valid javascript as well because if there are no sebsequent <script sequences the html pa...
if
javascript
facebook/react
packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js
https://github.com/facebook/react/blob/master/packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js
MIT
if (typeof value !== 'string') { throw new Error( 'File/Blob fields are not yet supported in progressive forms. ' + 'Will fallback to client hydration.', ); }
This escaping function is designed to work with with inline scripts where the entire contents are escaped. Because we know we are escaping the entire script we can avoid for instance escaping html comment string sequences that are valid javascript as well because if there are no sebsequent <script sequences the html pa...
if
javascript
facebook/react
packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js
https://github.com/facebook/react/blob/master/packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js
MIT
if (formData != null) { // $FlowFixMe[prop-missing]: FormData has forEach. formData.forEach(validateAdditionalFormField); }
This escaping function is designed to work with with inline scripts where the entire contents are escaped. Because we know we are escaping the entire script we can avoid for instance escaping html comment string sequences that are valid javascript as well because if there are no sebsequent <script sequences the html pa...
if
javascript
facebook/react
packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js
https://github.com/facebook/react/blob/master/packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js
MIT
validateAdditionalFormFields(customFields.data); } return customFields; } catch (x) { if (typeof x === 'object' && x !== null && typeof x.then === 'function') { // Rethrow suspense. throw x; } // If we fail to encode the form action for progressive enhancement for some ...
This escaping function is designed to work with with inline scripts where the entire contents are escaped. Because we know we are escaping the entire script we can avoid for instance escaping html comment string sequences that are valid javascript as well because if there are no sebsequent <script sequences the html pa...
validateAdditionalFormFields
javascript
facebook/react
packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js
https://github.com/facebook/react/blob/master/packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js
MIT
let formData = null; if (typeof formAction === 'function') { // Function form actions cannot control the form properties if (__DEV__) { if (name !== null && !didWarnFormActionName) { didWarnFormActionName = true; console.error( 'Cannot specify a "name" prop for a button that sp...
This escaping function is designed to work with with inline scripts where the entire contents are escaped. Because we know we are escaping the entire script we can avoid for instance escaping html comment string sequences that are valid javascript as well because if there are no sebsequent <script sequences the html pa...
let
javascript
facebook/react
packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js
https://github.com/facebook/react/blob/master/packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js
MIT
if (blobCache === null) { blobCache = new WeakMap(); }
This escaping function is designed to work with with inline scripts where the entire contents are escaped. Because we know we are escaping the entire script we can avoid for instance escaping html comment string sequences that are valid javascript as well because if there are no sebsequent <script sequences the html pa...
if
javascript
facebook/react
packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js
https://github.com/facebook/react/blob/master/packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js
MIT
if (__DEV__) { if (!nonceStyle && nonce) { console.error( 'React encountered a style tag with `precedence` "%s" and `nonce` "%s". When React manages style rules using `precedence` it will only include a nonce attributes if you also provide the same style nonce value as a render option.', ...
This escaping function is designed to work with with inline scripts where the entire contents are escaped. Because we know we are escaping the entire script we can avoid for instance escaping html comment string sequences that are valid javascript as well because if there are no sebsequent <script sequences the html pa...
if
javascript
facebook/react
packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js
https://github.com/facebook/react/blob/master/packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js
MIT
if ( props.fetchPriority === 'high' || renderState.highImagePreloads.size < 10 ) { // Delete the resource from the map since we are promoting it and don't want to // reenter this branch in a second pass for duplicate img hrefs. promotablePreloads.delete(key); // $F...
This escaping function is designed to work with style tag textContent only. While untrusted style content should be made safe before using this api it will ensure that the style cannot be early terminated or never terminated state
if
javascript
facebook/react
packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js
https://github.com/facebook/react/blob/master/packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js
MIT
for (i = 0; i < headChunks.length; i++) { writeChunk(destination, headChunks[i]); }
This escaping function is designed to work with style tag textContent only. While untrusted style content should be made safe before using this api it will ensure that the style cannot be early terminated or never terminated state
for
javascript
facebook/react
packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js
https://github.com/facebook/react/blob/master/packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js
MIT
writeBlockingRenderInstruction(destination, resumableState, renderState); } else { // We don't need to add the shell id so mark it as if sent. // Currently it might still be sent if it was already added to a bootstrap script. resumableState.instructions |= SentCompletedShellId; }
This escaping function is designed to work with style tag textContent only. While untrusted style content should be made safe before using this api it will ensure that the style cannot be early terminated or never terminated state
writeBlockingRenderInstruction
javascript
facebook/react
packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js
https://github.com/facebook/react/blob/master/packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js
MIT
if (resumableState.hasBody) { writeChunk(destination, endChunkForTag('body')); }
This escaping function is designed to work with style tag textContent only. While untrusted style content should be made safe before using this api it will ensure that the style cannot be early terminated or never terminated state
if
javascript
facebook/react
packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js
https://github.com/facebook/react/blob/master/packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js
MIT
if (resumableState.hasHtml) { writeChunk(destination, endChunkForTag('html')); }
This escaping function is designed to work with style tag textContent only. While untrusted style content should be made safe before using this api it will ensure that the style cannot be early terminated or never terminated state
if
javascript
facebook/react
packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js
https://github.com/facebook/react/blob/master/packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js
MIT
function hyphenateStyleName(name: string): string { return name .replace(uppercasePattern, '-$1') .toLowerCase() .replace(msPattern, '-ms-'); }
Hyphenates a camelcased CSS property name, for example: > hyphenateStyleName('backgroundColor') < "background-color" > hyphenateStyleName('MozTransition') < "-moz-transition" > hyphenateStyleName('msTransition') < "-ms-transition" As Modernizr suggests (http://modernizr.com/docs/#prefixed), an `ms` prefix...
hyphenateStyleName
javascript
facebook/react
packages/react-dom-bindings/src/shared/hyphenateStyleName.js
https://github.com/facebook/react/blob/master/packages/react-dom-bindings/src/shared/hyphenateStyleName.js
MIT
function mountSafeCallback_NOT_REALLY_SAFE( context: any, callback: ?Function, ): any { return function () { if (!callback) { return undefined; } // This protects against createClass() components. // We don't know if there is code depending on it. // We intentionally don't use isMounted(...
In the future, we should cleanup callbacks by cancelling them instead of using this.
mountSafeCallback_NOT_REALLY_SAFE
javascript
facebook/react
packages/react-native-renderer/src/NativeMethodsMixinUtils.js
https://github.com/facebook/react/blob/master/packages/react-native-renderer/src/NativeMethodsMixinUtils.js
MIT
function warnForStyleProps(props: any, validAttributes: any) { if (__DEV__) { for (const key in validAttributes.style) { if (!(validAttributes[key] || props[key] === undefined)) { console.error( 'You are setting the style `{ %s' + ': ... }` as a prop. You ' + 'shoul...
In the future, we should cleanup callbacks by cancelling them instead of using this.
warnForStyleProps
javascript
facebook/react
packages/react-native-renderer/src/NativeMethodsMixinUtils.js
https://github.com/facebook/react/blob/master/packages/react-native-renderer/src/NativeMethodsMixinUtils.js
MIT
function defaultDiffer(prevProp: mixed, nextProp: mixed): boolean { if (typeof nextProp !== 'object' || nextProp === null) { // Scalars have already been checked for equality return true; } else { // For objects and arrays, the default diffing algorithm is a deep compare return deepDiffer(prevProp, ...
Create a payload that contains all the updates between two sets of props. These helpers are all encapsulated into a single module, because they use mutation as a performance optimization which leads to subtle shared dependencies between the code paths. To avoid this mutable state leaking across modules, I've kept them...
defaultDiffer
javascript
facebook/react
packages/react-native-renderer/src/ReactNativeAttributePayload.js
https://github.com/facebook/react/blob/master/packages/react-native-renderer/src/ReactNativeAttributePayload.js
MIT
function restoreDeletedValuesInNestedArray( updatePayload: Object, node: NestedNode, validAttributes: AttributeConfiguration, ) { if (isArray(node)) { let i = node.length; while (i-- && removedKeyCount > 0) { restoreDeletedValuesInNestedArray( updatePayload, node[i], validA...
Create a payload that contains all the updates between two sets of props. These helpers are all encapsulated into a single module, because they use mutation as a performance optimization which leads to subtle shared dependencies between the code paths. To avoid this mutable state leaking across modules, I've kept them...
restoreDeletedValuesInNestedArray
javascript
facebook/react
packages/react-native-renderer/src/ReactNativeAttributePayload.js
https://github.com/facebook/react/blob/master/packages/react-native-renderer/src/ReactNativeAttributePayload.js
MIT
function diffNestedArrayProperty( updatePayload: null | Object, prevArray: Array<NestedNode>, nextArray: Array<NestedNode>, validAttributes: AttributeConfiguration, ): null | Object { const minLength = prevArray.length < nextArray.length ? prevArray.length : nextArray.length; let i; for (i = 0; i < mi...
Create a payload that contains all the updates between two sets of props. These helpers are all encapsulated into a single module, because they use mutation as a performance optimization which leads to subtle shared dependencies between the code paths. To avoid this mutable state leaking across modules, I've kept them...
diffNestedArrayProperty
javascript
facebook/react
packages/react-native-renderer/src/ReactNativeAttributePayload.js
https://github.com/facebook/react/blob/master/packages/react-native-renderer/src/ReactNativeAttributePayload.js
MIT
function diffNestedProperty( updatePayload: null | Object, prevProp: NestedNode, nextProp: NestedNode, validAttributes: AttributeConfiguration, ): null | Object { if (!updatePayload && prevProp === nextProp) { // If no properties have been added, then we can bail out quickly on object // equality. ...
Create a payload that contains all the updates between two sets of props. These helpers are all encapsulated into a single module, because they use mutation as a performance optimization which leads to subtle shared dependencies between the code paths. To avoid this mutable state leaking across modules, I've kept them...
diffNestedProperty
javascript
facebook/react
packages/react-native-renderer/src/ReactNativeAttributePayload.js
https://github.com/facebook/react/blob/master/packages/react-native-renderer/src/ReactNativeAttributePayload.js
MIT
function addNestedProperty( updatePayload: null | Object, nextProp: NestedNode, validAttributes: AttributeConfiguration, ): $FlowFixMe { if (!nextProp) { return updatePayload; } if (!isArray(nextProp)) { // Add each property of the leaf. return addProperties(updatePayload, nextProp, validAttrib...
addNestedProperty takes a single set of props and valid attribute attribute configurations. It processes each prop and adds it to the updatePayload.
addNestedProperty
javascript
facebook/react
packages/react-native-renderer/src/ReactNativeAttributePayload.js
https://github.com/facebook/react/blob/master/packages/react-native-renderer/src/ReactNativeAttributePayload.js
MIT
function clearNestedProperty( updatePayload: null | Object, prevProp: NestedNode, validAttributes: AttributeConfiguration, ): null | Object { if (!prevProp) { return updatePayload; } if (!isArray(prevProp)) { // Add each property of the leaf. return clearProperties(updatePayload, prevProp, vali...
clearNestedProperty takes a single set of props and valid attributes. It adds a null sentinel to the updatePayload, for each prop key.
clearNestedProperty
javascript
facebook/react
packages/react-native-renderer/src/ReactNativeAttributePayload.js
https://github.com/facebook/react/blob/master/packages/react-native-renderer/src/ReactNativeAttributePayload.js
MIT
function diffProperties( updatePayload: null | Object, prevProps: Object, nextProps: Object, validAttributes: AttributeConfiguration, ): null | Object { let attributeConfig; let nextProp; let prevProp; for (const propKey in nextProps) { attributeConfig = validAttributes[propKey]; if (!attribute...
diffProperties takes two sets of props and a set of valid attributes and write to updatePayload the values that changed or were deleted. If no updatePayload is provided, a new one is created and returned if anything changed.
diffProperties
javascript
facebook/react
packages/react-native-renderer/src/ReactNativeAttributePayload.js
https://github.com/facebook/react/blob/master/packages/react-native-renderer/src/ReactNativeAttributePayload.js
MIT
function addProperties( updatePayload: null | Object, props: Object, validAttributes: AttributeConfiguration, ): null | Object { // TODO: Fast path return diffProperties(updatePayload, emptyObject, props, validAttributes); }
addProperties adds all the valid props to the payload after being processed.
addProperties
javascript
facebook/react
packages/react-native-renderer/src/ReactNativeAttributePayload.js
https://github.com/facebook/react/blob/master/packages/react-native-renderer/src/ReactNativeAttributePayload.js
MIT
function clearProperties( updatePayload: null | Object, prevProps: Object, validAttributes: AttributeConfiguration, ): null | Object { // TODO: Fast path return diffProperties(updatePayload, prevProps, emptyObject, validAttributes); }
clearProperties clears all the previous props by adding a null sentinel to the payload for each valid key.
clearProperties
javascript
facebook/react
packages/react-native-renderer/src/ReactNativeAttributePayload.js
https://github.com/facebook/react/blob/master/packages/react-native-renderer/src/ReactNativeAttributePayload.js
MIT
function create( props: Object, validAttributes: AttributeConfiguration, ): null | Object { return addProperties( null, // updatePayload props, validAttributes, ); }
clearProperties clears all the previous props by adding a null sentinel to the payload for each valid key.
create
javascript
facebook/react
packages/react-native-renderer/src/ReactNativeAttributePayload.js
https://github.com/facebook/react/blob/master/packages/react-native-renderer/src/ReactNativeAttributePayload.js
MIT
function diff( prevProps: Object, nextProps: Object, validAttributes: AttributeConfiguration, ): null | Object { return diffProperties( null, // updatePayload prevProps, nextProps, validAttributes, ); }
clearProperties clears all the previous props by adding a null sentinel to the payload for each valid key.
diff
javascript
facebook/react
packages/react-native-renderer/src/ReactNativeAttributePayload.js
https://github.com/facebook/react/blob/master/packages/react-native-renderer/src/ReactNativeAttributePayload.js
MIT
function defaultDiffer(prevProp: mixed, nextProp: mixed): boolean { if (typeof nextProp !== 'object' || nextProp === null) { // Scalars have already been checked for equality return true; } else { // For objects and arrays, the default diffing algorithm is a deep compare return deepDiffer(prevProp, ...
Create a payload that contains all the updates between two sets of props. These helpers are all encapsulated into a single module, because they use mutation as a performance optimization which leads to subtle shared dependencies between the code paths. To avoid this mutable state leaking across modules, I've kept them...
defaultDiffer
javascript
facebook/react
packages/react-native-renderer/src/ReactNativeAttributePayloadFabric.js
https://github.com/facebook/react/blob/master/packages/react-native-renderer/src/ReactNativeAttributePayloadFabric.js
MIT
function restoreDeletedValuesInNestedArray( updatePayload: Object, node: NestedNode, validAttributes: AttributeConfiguration, ) { if (isArray(node)) { let i = node.length; while (i-- && removedKeyCount > 0) { restoreDeletedValuesInNestedArray( updatePayload, node[i], validA...
Create a payload that contains all the updates between two sets of props. These helpers are all encapsulated into a single module, because they use mutation as a performance optimization which leads to subtle shared dependencies between the code paths. To avoid this mutable state leaking across modules, I've kept them...
restoreDeletedValuesInNestedArray
javascript
facebook/react
packages/react-native-renderer/src/ReactNativeAttributePayloadFabric.js
https://github.com/facebook/react/blob/master/packages/react-native-renderer/src/ReactNativeAttributePayloadFabric.js
MIT
function diffNestedArrayProperty( updatePayload: null | Object, prevArray: Array<NestedNode>, nextArray: Array<NestedNode>, validAttributes: AttributeConfiguration, ): null | Object { const minLength = prevArray.length < nextArray.length ? prevArray.length : nextArray.length; let i; for (i = 0; i < mi...
Create a payload that contains all the updates between two sets of props. These helpers are all encapsulated into a single module, because they use mutation as a performance optimization which leads to subtle shared dependencies between the code paths. To avoid this mutable state leaking across modules, I've kept them...
diffNestedArrayProperty
javascript
facebook/react
packages/react-native-renderer/src/ReactNativeAttributePayloadFabric.js
https://github.com/facebook/react/blob/master/packages/react-native-renderer/src/ReactNativeAttributePayloadFabric.js
MIT
function diffNestedProperty( updatePayload: null | Object, prevProp: NestedNode, nextProp: NestedNode, validAttributes: AttributeConfiguration, ): null | Object { if (!updatePayload && prevProp === nextProp) { // If no properties have been added, then we can bail out quickly on object // equality. ...
Create a payload that contains all the updates between two sets of props. These helpers are all encapsulated into a single module, because they use mutation as a performance optimization which leads to subtle shared dependencies between the code paths. To avoid this mutable state leaking across modules, I've kept them...
diffNestedProperty
javascript
facebook/react
packages/react-native-renderer/src/ReactNativeAttributePayloadFabric.js
https://github.com/facebook/react/blob/master/packages/react-native-renderer/src/ReactNativeAttributePayloadFabric.js
MIT