Skip to content

Commit

Permalink
refactor(lib): don't destructure react-property and utilities
Browse files Browse the repository at this point in the history
  • Loading branch information
remarkablemark committed Sep 7, 2021
1 parent 20981f3 commit 9ebecd4
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions lib/attributes-to-props.js
@@ -1,12 +1,6 @@
var reactProperty = require('react-property');
var utilities = require('./utilities');

var setStyleProp = utilities.setStyleProp;

var htmlProperties = reactProperty.html;
var svgProperties = reactProperty.svg;
var isCustomAttribute = reactProperty.isCustomAttribute;

var hasOwnProperty = Object.prototype.hasOwnProperty;

/**
Expand All @@ -28,15 +22,15 @@ function attributesToProps(attributes) {
attributeValue = attributes[attributeName];

// ARIA (aria-*) or custom data (data-*) attribute
if (isCustomAttribute(attributeName)) {
if (reactProperty.isCustomAttribute(attributeName)) {
props[attributeName] = attributeValue;
continue;
}

// convert HTML attribute to React prop
attributeNameLowerCased = attributeName.toLowerCase();
if (hasOwnProperty.call(htmlProperties, attributeNameLowerCased)) {
property = htmlProperties[attributeNameLowerCased];
if (hasOwnProperty.call(reactProperty.html, attributeNameLowerCased)) {
property = reactProperty.html[attributeNameLowerCased];
props[property.propertyName] =
property.hasBooleanValue ||
(property.hasOverloadedBooleanValue && !attributeValue)
Expand All @@ -46,8 +40,8 @@ function attributesToProps(attributes) {
}

// convert SVG attribute to React prop
if (hasOwnProperty.call(svgProperties, attributeName)) {
property = svgProperties[attributeName];
if (hasOwnProperty.call(reactProperty.svg, attributeName)) {
property = reactProperty.svg[attributeName];
props[property.propertyName] = attributeValue;
continue;
}
Expand All @@ -59,7 +53,7 @@ function attributesToProps(attributes) {
}

// transform inline style to object
setStyleProp(attributes.style, props);
utilities.setStyleProp(attributes.style, props);

return props;
}
Expand Down

0 comments on commit 9ebecd4

Please sign in to comment.