Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use an ordered property list for inputs, fix some Chrome number input issues #7474

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove mutation methods
  • Loading branch information
nhunzaker committed Sep 29, 2016
commit 5e92612bbe4ebb6403c8da8b528745a7aafa5cf5
1 change: 1 addition & 0 deletions src/renderers/dom/client/wrappers/ReactDOMInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ var ReactDOMInput = {

function _handleChange(event) {
var props = this._currentElement.props;

var returnValue = LinkedValueUtils.executeOnChange(props, event);

// Here we use asap to wait until all updates have propagated, which
Expand Down
16 changes: 3 additions & 13 deletions src/renderers/dom/shared/DOMProperty.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@ var DOMPropertyInjection = {
* DOMPropertyNames: similar to DOMAttributeNames but for DOM properties.
* Property names not specified use the normalized name.
*
* DOMMutationMethods: Properties that require special mutation methods. If
* `value` is undefined, the mutation method should unset the property.
*
* @param {object} domPropertyConfig the config as described above.
*/
injectDOMPropertyConfig: function(domPropertyConfig) {
Expand All @@ -63,7 +60,6 @@ var DOMPropertyInjection = {
var DOMAttributeNamespaces = domPropertyConfig.DOMAttributeNamespaces || {};
var DOMAttributeNames = domPropertyConfig.DOMAttributeNames || {};
var DOMPropertyNames = domPropertyConfig.DOMPropertyNames || {};
var DOMMutationMethods = domPropertyConfig.DOMMutationMethods || {};

if (domPropertyConfig.isCustomAttribute) {
DOMProperty._isCustomAttributeFunctions.push(
Expand All @@ -77,7 +73,7 @@ var DOMPropertyInjection = {
var propConfig = property[1];

invariant(
!DOMProperty.properties.filter(i => i.propertyName === propName).length,
!DOMProperty.propertyOrder.hasOwnProperty(propName),
'injectDOMPropertyConfig(...): You\'re trying to inject DOM property ' +
'\'%s\' which has already been injected. You may be accidentally ' +
'injecting the same DOM property config twice, or you may be ' +
Expand All @@ -89,7 +85,6 @@ var DOMPropertyInjection = {
attributeName: lowerCased,
attributeNamespace: null,
propertyName: propName,
mutationMethod: null,

mustUseProperty: checkMask(propConfig, Injection.MUST_USE_PROPERTY),
noMarkup: checkMask(propConfig, Injection.NO_MARKUP),
Expand Down Expand Up @@ -129,10 +124,6 @@ var DOMPropertyInjection = {
propertyInfo.propertyName = DOMPropertyNames[propName];
}

if (DOMMutationMethods.hasOwnProperty(propName)) {
propertyInfo.mutationMethod = DOMMutationMethods[propName];
}

DOMProperty.propertyOrder[propName] = DOMProperty.properties.push(propertyInfo) - 1;
})
},
Expand Down Expand Up @@ -174,11 +165,10 @@ var DOMProperty = {
* propertyName:
* Used on DOM node instances. (This includes properties that mutate due to
* external factors.)
* mutationMethod:
* If non-null, used instead of the property or `setAttribute()` after
* initial render.
* mustUseProperty:
* Whether the property must be accessed and mutated as an object property.
* noMarkup:
* Whether the property will generate HTML when rendered to a string.
* hasBooleanValue:
* Whether the property should be removed when set to a falsey value.
* hasNumericValue:
Expand Down
10 changes: 2 additions & 8 deletions src/renderers/dom/shared/DOMPropertyOperations.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,7 @@ var DOMPropertyOperations = {
var propertyInfo = DOMProperty.getProperty(name)

if (propertyInfo) {
var mutationMethod = propertyInfo.mutationMethod;
if (mutationMethod) {
mutationMethod(node, value);
} else if (shouldIgnoreValue(propertyInfo, value)) {
if (shouldIgnoreValue(propertyInfo, value)) {
this.deleteValueForProperty(node, name);
return;
} else if (propertyInfo.mustUseProperty) {
Expand Down Expand Up @@ -225,10 +222,7 @@ var DOMPropertyOperations = {
var propertyInfo = DOMProperty.getProperty(name);

if (propertyInfo) {
var mutationMethod = propertyInfo.mutationMethod;
if (mutationMethod) {
mutationMethod(node, undefined);
} else if (propertyInfo.mustUseProperty) {
if (propertyInfo.mustUseProperty) {
var propName = propertyInfo.propertyName;
if (propertyInfo.hasBooleanValue) {
node[propName] = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ describe('DOMPropertyOperations', () => {
expect(stubNode.hasAttribute('data-foo')).toBe(false);
});

<<<<<<< a2e0258ebfc05358cd87ecd335a848eb7f6a1ab5
it('should use mutation method where applicable', () => {
var foobarSetter = jest.fn();
// inject foobar DOM property
Expand Down