mirror of
https://github.com/zebrajr/react.git
synced 2026-01-15 12:15:22 +00:00
Merge pull request #5261 from spicyj/dom-null-undef
Bug fixes for createElement mode
This commit is contained in:
@@ -163,7 +163,8 @@ var HTMLDOMPropertyConfig = {
|
||||
tabIndex: null,
|
||||
target: null,
|
||||
title: null,
|
||||
type: null,
|
||||
// Setting .type throws on non-<input> tags
|
||||
type: MUST_USE_ATTRIBUTE,
|
||||
useMap: null,
|
||||
value: MUST_USE_PROPERTY | HAS_SIDE_EFFECTS,
|
||||
width: MUST_USE_ATTRIBUTE,
|
||||
|
||||
@@ -937,7 +937,8 @@ ReactDOMComponent.Mixin = {
|
||||
var styleUpdates;
|
||||
for (propKey in lastProps) {
|
||||
if (nextProps.hasOwnProperty(propKey) ||
|
||||
!lastProps.hasOwnProperty(propKey)) {
|
||||
!lastProps.hasOwnProperty(propKey) ||
|
||||
lastProps[propKey] == null) {
|
||||
continue;
|
||||
}
|
||||
if (propKey === STYLE) {
|
||||
@@ -967,7 +968,9 @@ ReactDOMComponent.Mixin = {
|
||||
var lastProp = propKey === STYLE ?
|
||||
this._previousStyleCopy :
|
||||
lastProps[propKey];
|
||||
if (!nextProps.hasOwnProperty(propKey) || nextProp === lastProp) {
|
||||
if (!nextProps.hasOwnProperty(propKey) ||
|
||||
nextProp === lastProp ||
|
||||
nextProp == null && lastProp == null) {
|
||||
continue;
|
||||
}
|
||||
if (propKey === STYLE) {
|
||||
|
||||
@@ -426,6 +426,24 @@ describe('ReactDOMComponent', function() {
|
||||
ReactDOM.render(<button is="test" cowabunga="chevynova"/>, container);
|
||||
expect(container.firstChild.hasAttribute('cowabunga')).toBe(true);
|
||||
});
|
||||
|
||||
it('should not update when switching between null/undefined', function() {
|
||||
var container = document.createElement('div');
|
||||
var node = ReactDOM.render(<div />, container);
|
||||
|
||||
var setter = mocks.getMockFunction();
|
||||
Object.defineProperty(node, 'dir', {
|
||||
get: function() {},
|
||||
set: setter,
|
||||
});
|
||||
|
||||
ReactDOM.render(<div dir={null} />, container);
|
||||
ReactDOM.render(<div dir={undefined} />, container);
|
||||
ReactDOM.render(<div />, container);
|
||||
expect(setter.mock.calls.length).toBe(0);
|
||||
ReactDOM.render(<div dir="ltr" />, container);
|
||||
expect(setter.mock.calls.length).toBe(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe('createOpenTagMarkup', function() {
|
||||
|
||||
Reference in New Issue
Block a user