react-dom
Advanced tools
Comparing version 15.4.2 to 15.5.0-rc.1
@@ -268,2 +268,22 @@ /** | ||
function handleControlledInputBlur(inst, node) { | ||
// TODO: In IE, inst is occasionally null. Why? | ||
if (inst == null) { | ||
return; | ||
} | ||
// Fiber and ReactDOM keep wrapper state in separate places | ||
var state = inst._wrapperState || node._wrapperState; | ||
if (!state || !state.controlled || node.type !== 'number') { | ||
return; | ||
} | ||
// If controlled, assign the value attribute to the current value on blur | ||
var value = '' + node.value; | ||
if (node.getAttribute('value') !== value) { | ||
node.setAttribute('value', value); | ||
} | ||
} | ||
/** | ||
@@ -317,2 +337,7 @@ * This plugin creates an `onChange` event that normalizes change events | ||
} | ||
// When blurring, set the value attribute for number inputs | ||
if (topLevelType === 'topBlur') { | ||
handleControlledInputBlur(targetInst, targetNode); | ||
} | ||
} | ||
@@ -319,0 +344,0 @@ |
@@ -208,5 +208,29 @@ /** | ||
}, | ||
DOMPropertyNames: {} | ||
DOMPropertyNames: {}, | ||
DOMMutationMethods: { | ||
value: function (node, value) { | ||
if (value == null) { | ||
return node.removeAttribute('value'); | ||
} | ||
// Number inputs get special treatment due to some edge cases in | ||
// Chrome. Let everything else assign the value attribute as normal. | ||
// https://github.com/facebook/react/issues/7253#issuecomment-236074326 | ||
if (node.type !== 'number' || node.hasAttribute('value') === false) { | ||
node.setAttribute('value', '' + value); | ||
} else if (node.validity && !node.validity.badInput && node.ownerDocument.activeElement !== node) { | ||
// Don't assign an attribute if validation reports bad | ||
// input. Chrome will clear the value. Additionally, don't | ||
// operate on inputs that have focus, otherwise Chrome might | ||
// strip off trailing decimal places and cause the user's | ||
// cursor position to jump to the beginning of the input. | ||
// | ||
// In ReactDOMInput, we have an onBlur event that will trigger | ||
// this function again when focus is lost. | ||
node.setAttribute('value', '' + value); | ||
} | ||
} | ||
} | ||
}; | ||
module.exports = HTMLDOMPropertyConfig; |
@@ -20,3 +20,3 @@ /** | ||
var getNextDebugID = require('./getNextDebugID'); | ||
var getNextDebugID = require('react/lib/getNextDebugID'); | ||
var invariant = require('fbjs/lib/invariant'); | ||
@@ -29,5 +29,2 @@ var warning = require('fbjs/lib/warning'); | ||
}; | ||
_assign(ReactCompositeComponentWrapper.prototype, ReactCompositeComponent, { | ||
_instantiateReactComponent: instantiateReactComponent | ||
}); | ||
@@ -129,2 +126,6 @@ function getDeclarationErrorAddendum(owner) { | ||
_assign(ReactCompositeComponentWrapper.prototype, ReactCompositeComponent, { | ||
_instantiateReactComponent: instantiateReactComponent | ||
}); | ||
module.exports = instantiateReactComponent; |
@@ -517,3 +517,3 @@ /** | ||
if (process.env.NODE_ENV !== 'production') { | ||
this._checkContextTypes(Component.childContextTypes, childContext, 'childContext'); | ||
this._checkContextTypes(Component.childContextTypes, childContext, 'child context'); | ||
} | ||
@@ -520,0 +520,0 @@ for (var name in childContext) { |
@@ -181,5 +181,3 @@ /** | ||
var lastMarkTimeStamp = 0; | ||
var canUsePerformanceMeasure = | ||
// $FlowFixMe https://github.com/facebook/flow/issues/2345 | ||
typeof performance !== 'undefined' && typeof performance.mark === 'function' && typeof performance.clearMarks === 'function' && typeof performance.measure === 'function' && typeof performance.clearMeasures === 'function'; | ||
var canUsePerformanceMeasure = typeof performance !== 'undefined' && typeof performance.mark === 'function' && typeof performance.clearMarks === 'function' && typeof performance.measure === 'function' && typeof performance.clearMeasures === 'function'; | ||
@@ -186,0 +184,0 @@ function shouldMark(debugID) { |
@@ -115,8 +115,5 @@ /** | ||
listeners: null, | ||
onChange: _handleChange.bind(inst) | ||
onChange: _handleChange.bind(inst), | ||
controlled: isControlled(props) | ||
}; | ||
if (process.env.NODE_ENV !== 'production') { | ||
inst._wrapperState.controlled = isControlled(props); | ||
} | ||
}, | ||
@@ -150,10 +147,20 @@ | ||
if (value != null) { | ||
if (value === 0 && node.value === '') { | ||
node.value = '0'; | ||
// Note: IE9 reports a number inputs as 'text', so check props instead. | ||
} else if (props.type === 'number') { | ||
// Simulate `input.valueAsNumber`. IE9 does not support it | ||
var valueAsNumber = parseFloat(node.value, 10) || 0; | ||
// Cast `value` to a string to ensure the value is set correctly. While | ||
// browsers typically do this as necessary, jsdom doesn't. | ||
var newValue = '' + value; | ||
// To avoid side effects (such as losing text selection), only set value if changed | ||
if (newValue !== node.value) { | ||
node.value = newValue; | ||
// eslint-disable-next-line | ||
if (value != valueAsNumber) { | ||
// Cast `value` to a string to ensure the value is set correctly. While | ||
// browsers typically do this as necessary, jsdom doesn't. | ||
node.value = '' + value; | ||
} | ||
// eslint-disable-next-line | ||
} else if (value != node.value) { | ||
// Cast `value` to a string to ensure the value is set correctly. While | ||
// browsers typically do this as necessary, jsdom doesn't. | ||
node.value = '' + value; | ||
} | ||
@@ -160,0 +167,0 @@ } else { |
@@ -68,3 +68,2 @@ /** | ||
var evt = document.createEvent('Event'); | ||
// $FlowFixMe https://github.com/facebook/flow/issues/2336 | ||
evt.initEvent(evtType, false, false); | ||
@@ -71,0 +70,0 @@ fakeNode.dispatchEvent(evt); |
@@ -349,3 +349,3 @@ /** | ||
case HostComponent: | ||
if (workInProgress.stateNode && config.beginUpdate) { | ||
if (workInProgress.stateNode && typeof config.beginUpdate === 'function') { | ||
config.beginUpdate(workInProgress.stateNode); | ||
@@ -352,0 +352,0 @@ } |
@@ -19,11 +19,17 @@ /** | ||
var React = require('react/lib/React'); | ||
var ReactDefaultInjection = require('./ReactDefaultInjection'); | ||
var ReactCompositeComponent = require('./ReactCompositeComponent'); | ||
var ReactDefaultBatchingStrategy = require('./ReactDefaultBatchingStrategy'); | ||
var ReactReconciler = require('./ReactReconciler'); | ||
var ReactTestReconcileTransaction = require('./ReactTestReconcileTransaction'); | ||
var ReactUpdates = require('./ReactUpdates'); | ||
var emptyObject = require('fbjs/lib/emptyObject'); | ||
var getNextDebugID = require('./getNextDebugID'); | ||
var getNextDebugID = require('react/lib/getNextDebugID'); | ||
var invariant = require('fbjs/lib/invariant'); | ||
// Ensure we've done the default injections. | ||
// This might not be true in the case of a simple test that only requires React + ReactShallowRenderer. | ||
ReactUpdates.injection.injectReconcileTransaction(ReactTestReconcileTransaction); | ||
ReactUpdates.injection.injectBatchingStrategy(ReactDefaultBatchingStrategy); | ||
var NoopInternalComponent = function () { | ||
@@ -96,7 +102,2 @@ function NoopInternalComponent(element) { | ||
ReactShallowRenderer.prototype.render = function render(element, context) { | ||
// Ensure we've done the default injections. This might not be true in the | ||
// case of a simple test that only requires React and the TestUtils in | ||
// conjunction with an inline-requires transform. | ||
ReactDefaultInjection.inject(); | ||
!React.isValidElement(element) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactShallowRenderer render(): Invalid component element.%s', typeof element === 'function' ? ' Instead of passing a component class, make sure to instantiate ' + 'it by passing it to React.createElement.' : '') : _prodInvariant('12', typeof element === 'function' ? ' Instead of passing a component class, make sure to instantiate ' + 'it by passing it to React.createElement.' : '') : void 0; | ||
@@ -103,0 +104,0 @@ !(typeof element.type !== 'string') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactShallowRenderer render(): Shallow rendering works only with custom components, not primitives (%s). Instead of calling `.render(el)` and inspecting the rendered output, look at `el.props` directly instead.', element.type) : _prodInvariant('13', element.type) : void 0; |
@@ -36,2 +36,14 @@ /** | ||
// In react 16+ shallowRenderer will not be accessible via ReactTestUtils.createRenderer() | ||
// Instead it will be available via react-test-renderer/shallow | ||
// Maintain backwards compat for 15.5.0 release, but warn about using the deprecated method | ||
var hasWarnedAboutCreateRenderer = false; | ||
function createRendererWithWarning() { | ||
if (!hasWarnedAboutCreateRenderer) { | ||
hasWarnedAboutCreateRenderer = true; | ||
console.error('Shallow renderer has been moved to react-test-renderer/shallow. ' + 'Update references to remove this warning.'); | ||
} | ||
return new ReactShallowRenderer(); | ||
} | ||
/** | ||
@@ -293,5 +305,3 @@ * @class ReactTestUtils | ||
createRenderer: function () { | ||
return new ReactShallowRenderer(); | ||
}, | ||
createRenderer: createRendererWithWarning, | ||
@@ -298,0 +308,0 @@ Simulate: null, |
@@ -171,3 +171,3 @@ /** | ||
*/ | ||
enqueueReplaceState: function (publicInstance, completeState) { | ||
enqueueReplaceState: function (publicInstance, completeState, callback) { | ||
var internalInstance = getInternalInstanceReadyForUpdate(publicInstance, 'replaceState'); | ||
@@ -182,2 +182,12 @@ | ||
// Future-proof 15.5 | ||
if (callback !== undefined && callback !== null) { | ||
ReactUpdateQueue.validateCallback(callback, 'replaceState'); | ||
if (internalInstance._pendingCallbacks) { | ||
internalInstance._pendingCallbacks.push(callback); | ||
} else { | ||
internalInstance._pendingCallbacks = [callback]; | ||
} | ||
} | ||
enqueueUpdate(internalInstance); | ||
@@ -184,0 +194,0 @@ }, |
@@ -13,2 +13,2 @@ /** | ||
module.exports = '15.4.2'; | ||
module.exports = '15.5.0-rc.1'; |
@@ -227,12 +227,7 @@ /** | ||
case 'ul': | ||
case 'pre': | ||
case 'listing': | ||
case 'table': | ||
case 'hr': | ||
case 'xmp': | ||
case 'h1': | ||
@@ -239,0 +234,0 @@ case 'h2': |
{ | ||
"name": "react-dom", | ||
"version": "15.4.2", | ||
"version": "15.5.0-rc.1", | ||
"description": "React package for working with the DOM.", | ||
@@ -16,3 +16,3 @@ "main": "index.js", | ||
"dependencies": { | ||
"fbjs": "^0.8.1", | ||
"fbjs": "^0.8.9", | ||
"loose-envify": "^1.1.0", | ||
@@ -22,3 +22,3 @@ "object-assign": "^4.1.0" | ||
"peerDependencies": { | ||
"react": "^15.4.2" | ||
"react": "^15.5.0-rc.1" | ||
}, | ||
@@ -25,0 +25,0 @@ "files": [ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 5 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 3 instances in 1 package
2143154
49435
356
37
3
Updatedfbjs@^0.8.9