
Research
5 Malicious Chrome Extensions Enable Session Hijacking in Enterprise HR and ERP Systems
Five coordinated Chrome extensions enable session hijacking and block security controls across enterprise HR and ERP platforms.
pick-html-attribute-props
Advanced tools
Pickers and other helper functions used to filter standard HTML attribute values from an object
"Pickers" and other helper functions used to filter standard HTML attribute values from an object.
NOTE: This library was created with the intent to be used by React components, but React is not required to use this library.
$ npm i --save pick-html-attribute-props
import React from 'react';
import {
pickFormHtmlAttrProps,
pickGlobalHtmlAttrProps,
pickInputHtmlAttrProps,
pickTextAreaHtmlAttrProps
} from 'pick-html-attribute-props';
export function MyComponent(props) {
return (
<div {...pickGlobalHtmlAttrProps(props)}>
{/* ... */}
</div>
);
}
export function MyFormComponent(props) {
return (
<form {...pickFormHtmlAttrProps(props)} {/* ... */}>
{/* ... */}
</form>
);
}
export function MyInputComponent(props) {
return (
<input {...pickInputHtmlAttrProps(props)} {/* ... */} />
);
}
export function MyTextAreaComponent(props) {
return (
<textarea {...pickTextAreaHtmlAttrProps(props)}>
{/* ... */}
</textarea>
);
}
Creates a new object composed of properties "picked" from obj that are valid HTML Form
attributes or are event handlers (unless specified otherwise in
options) found in the given obj. If obj is not defined, then an empty object is
returned.
Parameters
?Object - object to be used when searching for HTML attribute values.?Boolean - when true, event handlers will
be omitted from the returned object.Returns !Object
options.omitEventHandlers is true,
then all event handlers will be omitted form the returned object). If none are found,
then an empty object is returned.Examples
import { pickFormHtmlAttrProps } from 'pick-html-attribute-props';
pickFormHtmlAttrProps(null); // returns `{}`
pickFormHtmlAttrProps({
id: 42,
type: 'text',
defaultValue: 'Fish fingers and custard',
className: 'my-class-name',
onChange: handleChange,
"data-id": "myDataId",
"aria-blah": "myAriaProp"
}); // returns a new object that contains all of the properties in the original object
pickFormHtmlAttrProps({ onChange: handleChange }, { omitEventHandlers: true }); // returns `{}` (event handlers are being ommitted from result)
pickFormHtmlAttrProps({ id: 42, name: "Doctor Who", blah: 78 }); // returns `{ id: 42, name: "Doctor Who" }` ("blah" is not a valid HTML Form attribute)
Creates a new object composed of properties "picked" from obj that are valid HTML
attributes that can be supplied to any HTML element or are
event handlers (unless specified otherwise in options) found in the given obj. If
obj is not defined, then an empty object is returned.
Parameters
?Object - object to be used when searching for HTML attribute values.?Boolean - when true, event handlers will
be omitted from the returned object.Returns !Object
options.omitEventHandlers is true, then all event handlers will be omitted form the
returned object). If none are found, then an empty object is returned.Examples
import { pickGlobalHtmlAttrProps } from 'pick-html-attribute-props';
pickGlobalHtmlAttrProps(null); // returns `{}`
pickGlobalHtmlAttrProps({
id: 42,
className: 'my-class-name',
onChange: handleChange,
"data-id": "myDataId",
"aria-blah": "myAriaProp"
}); // returns a new object that contains all of the properties in the original object
pickGlobalHtmlAttrProps({ onChange: handleChange }, { omitEventHandlers: true }); // returns `{}` (event handlers are being ommitted from result)
pickGlobalHtmlAttrProps({ id: 42, name: "Doctor Who", blah: 78 }); // returns `{ id: 42 }` ("name" & "blah" are not a valid HTML attribute for all HTML elements)
Creates a new object composed of properties "picked" from obj that are valid HTML Input
attributes or are event handlers (unless specified otherwise in
options) found in the given obj. If obj is not defined, then an empty object is
returned.
Parameters
?Object - object to be used when searching for HTML attribute values.?Boolean - when true, event handlers will
be omitted from the returned object.Returns !Object
options.omitEventHandlers is true,
then all event handlers will be omitted form the returned object). If none are found,
then an empty object is returned.Examples
import { pickInputHtmlAttrProps } from 'pick-html-attribute-props';
pickInputHtmlAttrProps(null); // returns `{}`
pickInputHtmlAttrProps({
id: 42,
type: 'text',
defaultValue: 'Fish fingers and custard',
className: 'my-class-name',
onChange: handleChange,
"data-id": "myDataId",
"aria-blah": "myAriaProp"
}); // returns a new object that contains all of the properties in the original object
pickInputHtmlAttrProps({ onChange: handleChange }, { omitEventHandlers: true }); // returns `{}` (event handlers are being ommitted from result)
pickInputHtmlAttrProps({ id: 42, name: "Doctor Who", blah: 78 }); // returns `{ id: 42, name: "Doctor Who" }` ("blah" is not a valid HTML Input attribute)
Creates a new object composed of properties "picked" from obj that are valid HTML
TextArea attributes and event handlers (unless specified otherwise
in options) found in the given obj. If obj is not defined, then an empty object is
returned.
Parameters
?Object - object to be used when searching for HTML attribute values.?Boolean - when true, event handlers will
be omitted from the returned object.Returns !Object
options.omitEventHandlers is
true, then all event handlers will be omitted form the returned object). If none are
found, then an empty object is returned.Examples
import { pickTextAreaHtmlAttrProps } from 'pick-html-attribute-props';
pickTextAreaHtmlAttrProps(null); // returns `{}`
pickTextAreaHtmlAttrProps({
id: 42,
defaultValue: 'Fish fingers and custard',
className: 'my-class-name',
onChange: handleChange,
"data-id": "myDataId",
"aria-blah": "myAriaProp"
}); // returns a new object that contains all of the properties in the original object
pickTextAreaHtmlAttrProps({ onChange: handleChange }, { omitEventHandlers: true }); // returns `{}` (event handlers are being ommitted from result)
pickTextAreaHtmlAttrProps({ id: 42, name: "Doctor Who", blah: 78 }); // returns `{ id: 42, name: "Doctor Who" }` ("blah" is not a valid HTML TextArea attribute)
Returns a list of attribute names that are valid for an HTML Form element.
NOTE: A list of attribute names returned can be found in
attr-names.js.
Example
import { getFormHtmlAttrNames } from 'pick-html-attribute-props/attr-names';
console.log(getFormHtmlAttrNames()); // list of attribute names that are valid for an HTML Form element
Returns a list of attribute names that are valid for any HTML element.
NOTE: A list of attribute names returned can be found in
attr-names.js.
Example
import { getGlobalHtmlAttrNames } from 'pick-html-attribute-props/attr-names';
console.log(getGlobalHtmlAttrNames()); // list of attribute names that are valid for any HTML element
Returns a list of attribute names that are valid for an HTML Input element.
NOTE: A list of attribute names returned can be found in
attr-names.js.
Example
import { getInputHtmlAttrNames } from 'pick-html-attribute-props/attr-names';
console.log(getInputHtmlAttrNames()); // list of attribute names that are valid for an HTML Input element
Returns a list of attribute names that are valid for an HTML TextArea element.
NOTE: A list of attribute names returned can be found in
attr-names.js.
Example
import { getTextAreaHtmlAttrNames } from 'pick-html-attribute-props/attr-names';
console.log(getTextAreaHtmlAttrNames()); // list of attribute names that are valid for an HTML TextArea element
Determines if the given propName represents a "data" or "aria" attribute.
Parameters
?String - the name of the property to check.Returns !Boolean
true if propName is a defined String and begins with begins with data- or
aria-; otherwise, false.Examples
import { propertyIsDataOrAriaAttr } from 'pick-html-attribute-props/prop-name-predicates';
console.log(propertyIsDataOrAriaAttr("data-blah")) // true
console.log(propertyIsDataOrAriaAttr("aria-blah")) // true
console.log(propertyIsDataOrAriaAttr(null)) // false (parameter isn't a String)
console.log(propertyIsDataOrAriaAttr("datablah")) // false (doesn't start with "data-")
console.log(propertyIsDataOrAriaAttr("ariablah")) // false (doesn't start with "aria-")
Determines if the given propName represents an event handler, a "data" attribute, or an
"aria" attribute.
Parameters
?String - the name of the property to check.Returns !Boolean
true if propName is a defined String and begins with on followed by a
capitalized letter, begins with data-, or begins with aria-; otherwise, false.Examples
import { propertyIsDataOrAriaAttrOrEventHandler } from 'pick-html-attribute-props/prop-name-predicates';
console.log(propertyIsDataOrAriaAttrOrEventHandler("onChange")); // true
console.log(propertyIsDataOrAriaAttrOrEventHandler("onBlah")); // true
console.log(propertyIsDataOrAriaAttrOrEventHandler("data-blah")) // true
console.log(propertyIsDataOrAriaAttrOrEventHandler("aria-blah")) // true
console.log(propertyIsDataOrAriaAttrOrEventHandler(null)) // false (parameter isn't a String)
console.log(propertyIsDataOrAriaAttrOrEventHandler("onchange")); // false ("on" is not followed by a capitalized letter)
console.log(propertyIsDataOrAriaAttrOrEventHandler("handleChange")); // false (doesn't start with "on")
console.log(propertyIsDataOrAriaAttrOrEventHandler("datablah")) // false (doesn't start with "data-")
console.log(propertyIsDataOrAriaAttrOrEventHandler("ariablah")) // false (doesn't start with "aria-")
Determines if the given propName likely represents an event handler.
Parameters
?String - the name of the property to check.Returns !Boolean
true if propName is a defined String and begins with on followed by a
capitalized letter; otherwise, false.Examples
import { propertyIsEventHandler } from 'pick-html-attribute-props/prop-name-predicates';
console.log(propertyIsEventHandler("onChange")); // true
console.log(propertyIsEventHandler("onBlah")); // true
console.log(propertyIsEventHandler(null)) // false (parameter isn't a String)
console.log(propertyIsEventHandler("onchange")); // false ("on" is not followed by a capitalized letter)
console.log(propertyIsEventHandler("handleChange")); // false (doesn't start with "on")
ISC License (ISC)
Copyright (c) 2024, Brandon D. Sara (https://bsara.dev/)
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
FAQs
Pickers and other helper functions used to filter standard HTML attribute values from an object
We found that pick-html-attribute-props demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
Five coordinated Chrome extensions enable session hijacking and block security controls across enterprise HR and ERP platforms.

Research
Node.js patched a crash bug where AsyncLocalStorage could cause stack overflows to bypass error handlers and terminate production servers.

Research
/Security News
A malicious Chrome extension steals newly created MEXC API keys, exfiltrates them to Telegram, and enables full account takeover with trading and withdrawal rights.