Socket
Socket
Sign inDemoInstall

filter-invalid-dom-props

Package Overview
Dependencies
1
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.0 to 2.0.0

2

dist/index.js

@@ -63,3 +63,3 @@ "use strict";

function isValidDOMProp(prop) {
return eventProps[prop] || _htmlAttributes2.default[prop];
return eventProps[prop] || _htmlAttributes2.default[prop] || /^(data|aria)-/.test(prop);
}

@@ -66,0 +66,0 @@

{
"name": "filter-invalid-dom-props",
"version": "1.0.0",
"version": "2.0.0",
"description": "a function to filter props that are not valid dom props when spreading props in an HOC in react",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

# Filter Invalid DOM Props
[![CircleCI](https://circleci.com/gh/socialtables/filter-invalid-dom-props.svg?style=svg)](https://circleci.com/gh/socialtables/filter-invalid-dom-props)
A simple helper function to filter out invalid dom properties. Useful when spreading into at html element in react applications (and maybe for other things).

@@ -32,2 +34,2 @@

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

@@ -52,3 +52,7 @@ import htmlAttributes from "html-attributes";

function isValidDOMProp(prop) {
return eventProps[prop] || htmlAttributes[prop];
return (
eventProps[prop] ||
htmlAttributes[prop] ||
/^(data|aria)-/.test(prop)
);
}

@@ -64,2 +68,2 @@

return domProps;
}
}

@@ -9,11 +9,15 @@ const test = require("tape");

type: "text",
christophercolumbus: "notcool"
christophercolumbus: "notcool",
"aria-label": "accessible",
"data-extra": "smart"
};
const filteredProps = filterDOMProps(properties);
assert.equal(Object.keys(filteredProps).length, 3);
assert.equal(Object.keys(filteredProps).length, 5);
assert.equal(filteredProps.value, properties.value);
assert.equal(filteredProps.onClick, properties.onClick);
assert.equal(filteredProps.type, properties.type);
assert.equal(filteredProps["aria-label"], properties["aria-label"]);
assert.equal(filteredProps["data-extra"], properties["data-extra"]);
assert.notEqual(filteredProps.christophercolumbus, properties.christophercolumbus);
assert.end();
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc