Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

property-information

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

property-information - npm Package Compare versions

Comparing version 3.1.0 to 3.2.0

489

index.js

@@ -1,18 +0,7 @@

/**
* @author Titus Wormer
* @copyright 2015 Titus Wormer
* @copyright 2013-2015 Facebook Inc.
* @license MIT
* @module property-information
* @fileoverview Information for HTML properties.
*/
'use strict';
/* eslint-env commonjs */
/* Expose. */
module.exports = getPropertyInformation;
/*
* Constants.
*/
/* Constants. */
var USE_ATTRIBUTE = 0x1;

@@ -27,230 +16,205 @@ var USE_PROPERTY = 0x2;

/**
* Check a mask.
*
* @param {string} value - Config.
* @param {number} bitmask - Mask.
* @return {boolean} - Whether `mask` matches `config`.
*/
function check(value, bitmask) {
return (value & bitmask) === bitmask;
}
/**
* Lower-case a string.
*
* @param {string} value - Content.
* @return {string} - Lower-cased `value`.
*/
function lower(value) {
return value.toLowerCase();
}
/*
* Map of properties.
* Names are camel-cased properties.
*/
/* Map of properties. Names are camel-cased properties. */
var propertyConfig = {
/*
* Standard Properties
*/
'abbr': null,
'accept': COMMA_SEPARATED,
'acceptCharset': SPACE_SEPARATED,
'accessKey': SPACE_SEPARATED,
'action': null,
'allowFullScreen': USE_ATTRIBUTE | BOOLEAN_VALUE,
'allowTransparency': USE_ATTRIBUTE,
'alt': null,
'async': BOOLEAN_VALUE,
'autoComplete': SPACE_SEPARATED,
'autoFocus': BOOLEAN_VALUE,
'autoPlay': BOOLEAN_VALUE,
'capture': USE_ATTRIBUTE | BOOLEAN_VALUE,
'cellPadding': null,
'cellSpacing': null,
'challenge': USE_ATTRIBUTE,
'charSet': USE_ATTRIBUTE,
'checked': USE_PROPERTY | BOOLEAN_VALUE,
'cite': null,
/* To set className on SVG elements, it's necessary to
* use .setAttribute; this works on HTML elements too
* in all browsers except IE8. */
'className': USE_ATTRIBUTE | SPACE_SEPARATED,
'cols': USE_ATTRIBUTE | POSITIVE_NUMERIC_VALUE,
'colSpan': null,
'command': null,
'content': null,
'contentEditable': null,
'contextMenu': USE_ATTRIBUTE,
'controls': USE_PROPERTY | BOOLEAN_VALUE,
'coords': NUMERIC_VALUE | COMMA_SEPARATED,
'crossOrigin': null,
/* For `<object />` acts as `src`. */
'data': null,
'dateTime': USE_ATTRIBUTE,
'default': BOOLEAN_VALUE,
'defer': BOOLEAN_VALUE,
'dir': null,
'dirName': null,
'disabled': USE_ATTRIBUTE | BOOLEAN_VALUE,
'download': OVERLOADED_BOOLEAN_VALUE,
'draggable': null,
'dropzone': SPACE_SEPARATED,
'encType': null,
'form': USE_ATTRIBUTE,
'formAction': USE_ATTRIBUTE,
'formEncType': USE_ATTRIBUTE,
'formMethod': USE_ATTRIBUTE,
'formNoValidate': BOOLEAN_VALUE,
'formTarget': USE_ATTRIBUTE,
'frameBorder': USE_ATTRIBUTE,
'headers': SPACE_SEPARATED,
'height': USE_ATTRIBUTE | POSITIVE_NUMERIC_VALUE,
'hidden': USE_ATTRIBUTE | BOOLEAN_VALUE,
'high': NUMERIC_VALUE,
'href': null,
'hrefLang': null,
'htmlFor': SPACE_SEPARATED,
'httpEquiv': SPACE_SEPARATED,
'icon': null,
'id': USE_PROPERTY,
'inputMode': USE_ATTRIBUTE,
/* Web Components */
'is': USE_ATTRIBUTE,
'isMap': BOOLEAN_VALUE,
'keyParams': USE_ATTRIBUTE,
'keyType': USE_ATTRIBUTE,
'kind': null,
'label': null,
'lang': null,
'list': USE_ATTRIBUTE,
'loop': USE_PROPERTY | BOOLEAN_VALUE,
'low': NUMERIC_VALUE,
'manifest': USE_ATTRIBUTE,
'marginHeight': NUMERIC_VALUE,
'marginWidth': NUMERIC_VALUE,
'max': null,
'maxLength': USE_ATTRIBUTE | POSITIVE_NUMERIC_VALUE,
'media': USE_ATTRIBUTE,
'mediaGroup': null,
'menu': null,
'method': null,
'min': null,
'minLength': USE_ATTRIBUTE | POSITIVE_NUMERIC_VALUE,
'multiple': USE_PROPERTY | BOOLEAN_VALUE,
'muted': USE_PROPERTY | BOOLEAN_VALUE,
'name': null,
'nonce': null,
'noValidate': BOOLEAN_VALUE,
'open': BOOLEAN_VALUE,
'optimum': NUMERIC_VALUE,
'pattern': null,
'ping': SPACE_SEPARATED,
'placeholder': null,
'poster': null,
'preload': null,
'radioGroup': null,
'readOnly': USE_PROPERTY | BOOLEAN_VALUE,
/* property is `relList` in DOM */
'rel': SPACE_SEPARATED | USE_ATTRIBUTE,
'required': BOOLEAN_VALUE,
'reversed': BOOLEAN_VALUE,
'role': USE_ATTRIBUTE,
'rows': USE_ATTRIBUTE | POSITIVE_NUMERIC_VALUE,
'rowSpan': POSITIVE_NUMERIC_VALUE,
'sandbox': SPACE_SEPARATED,
'scope': null,
'scoped': BOOLEAN_VALUE,
'scrolling': null,
'seamless': USE_ATTRIBUTE | BOOLEAN_VALUE,
'selected': USE_PROPERTY | BOOLEAN_VALUE,
'shape': null,
'size': USE_ATTRIBUTE | POSITIVE_NUMERIC_VALUE,
'sizes': USE_ATTRIBUTE | SPACE_SEPARATED,
'sortable': BOOLEAN_VALUE,
'sorted': SPACE_SEPARATED,
'span': POSITIVE_NUMERIC_VALUE,
'spellCheck': null,
'src': null,
'srcDoc': USE_PROPERTY,
'srcLang': null,
'srcSet': USE_ATTRIBUTE | COMMA_SEPARATED,
'start': NUMERIC_VALUE,
'step': null,
'style': null,
'summary': null,
'tabIndex': NUMERIC_VALUE,
'target': null,
'title': null,
'translate': null,
'type': null,
'typeMustMatch': BOOLEAN_VALUE,
'useMap': null,
'value': USE_PROPERTY,
'volume': POSITIVE_NUMERIC_VALUE,
'width': USE_ATTRIBUTE | NUMERIC_VALUE,
'wmode': USE_ATTRIBUTE,
'wrap': null,
/* Standard Properties. */
abbr: null,
accept: COMMA_SEPARATED,
acceptCharset: SPACE_SEPARATED,
accessKey: SPACE_SEPARATED,
action: null,
allowFullScreen: USE_ATTRIBUTE | BOOLEAN_VALUE,
allowTransparency: USE_ATTRIBUTE,
alt: null,
/* https://html.spec.whatwg.org/#attr-link-as */
as: null,
async: BOOLEAN_VALUE,
autoComplete: SPACE_SEPARATED,
autoFocus: BOOLEAN_VALUE,
autoPlay: BOOLEAN_VALUE,
capture: USE_ATTRIBUTE | BOOLEAN_VALUE,
cellPadding: null,
cellSpacing: null,
challenge: USE_ATTRIBUTE,
charSet: USE_ATTRIBUTE,
checked: USE_PROPERTY | BOOLEAN_VALUE,
cite: null,
/* To set className on SVG elements, it's necessary to
* use .setAttribute; this works on HTML elements too
* in all browsers except IE8. */
className: USE_ATTRIBUTE | SPACE_SEPARATED,
cols: USE_ATTRIBUTE | POSITIVE_NUMERIC_VALUE,
colSpan: null,
command: null,
content: null,
contentEditable: null,
contextMenu: USE_ATTRIBUTE,
controls: USE_PROPERTY | BOOLEAN_VALUE,
/* https://github.com/WICG/controls-list/blob/gh-pages/explainer.md */
controlsList: SPACE_SEPARATED,
coords: NUMERIC_VALUE | COMMA_SEPARATED,
crossOrigin: null,
/* For `<object />` acts as `src`. */
data: null,
dateTime: USE_ATTRIBUTE,
default: BOOLEAN_VALUE,
defer: BOOLEAN_VALUE,
dir: null,
dirName: null,
disabled: USE_ATTRIBUTE | BOOLEAN_VALUE,
download: OVERLOADED_BOOLEAN_VALUE,
draggable: null,
dropzone: SPACE_SEPARATED,
encType: null,
form: USE_ATTRIBUTE,
formAction: USE_ATTRIBUTE,
formEncType: USE_ATTRIBUTE,
formMethod: USE_ATTRIBUTE,
formNoValidate: BOOLEAN_VALUE,
formTarget: USE_ATTRIBUTE,
frameBorder: USE_ATTRIBUTE,
headers: SPACE_SEPARATED,
height: USE_ATTRIBUTE | POSITIVE_NUMERIC_VALUE,
hidden: USE_ATTRIBUTE | BOOLEAN_VALUE,
high: NUMERIC_VALUE,
href: null,
hrefLang: null,
htmlFor: SPACE_SEPARATED,
httpEquiv: SPACE_SEPARATED,
id: USE_PROPERTY,
inputMode: USE_ATTRIBUTE,
/* Web Components */
is: USE_ATTRIBUTE,
isMap: BOOLEAN_VALUE,
keyParams: USE_ATTRIBUTE,
keyType: USE_ATTRIBUTE,
kind: null,
label: null,
lang: null,
list: USE_ATTRIBUTE,
loop: USE_PROPERTY | BOOLEAN_VALUE,
low: NUMERIC_VALUE,
manifest: USE_ATTRIBUTE,
marginHeight: NUMERIC_VALUE,
marginWidth: NUMERIC_VALUE,
max: null,
maxLength: USE_ATTRIBUTE | POSITIVE_NUMERIC_VALUE,
media: USE_ATTRIBUTE,
mediaGroup: null,
menu: null,
method: null,
min: null,
minLength: USE_ATTRIBUTE | POSITIVE_NUMERIC_VALUE,
multiple: USE_PROPERTY | BOOLEAN_VALUE,
muted: USE_PROPERTY | BOOLEAN_VALUE,
name: null,
nonce: null,
noValidate: BOOLEAN_VALUE,
open: BOOLEAN_VALUE,
optimum: NUMERIC_VALUE,
pattern: null,
ping: SPACE_SEPARATED,
placeholder: null,
/* https://html.spec.whatwg.org/#attr-video-playsinline */
playsInline: BOOLEAN_VALUE,
poster: null,
preload: null,
/* https://html.spec.whatwg.org/#dom-head-profile */
profile: null,
radioGroup: null,
readOnly: USE_PROPERTY | BOOLEAN_VALUE,
/* https://html.spec.whatwg.org/#attr-link-referrerpolicy */
referrerPolicy: null,
/* `rel` is `relList` in DOM */
rel: SPACE_SEPARATED | USE_ATTRIBUTE,
required: BOOLEAN_VALUE,
reversed: BOOLEAN_VALUE,
role: USE_ATTRIBUTE,
rows: USE_ATTRIBUTE | POSITIVE_NUMERIC_VALUE,
rowSpan: POSITIVE_NUMERIC_VALUE,
sandbox: SPACE_SEPARATED,
scope: null,
scoped: BOOLEAN_VALUE,
scrolling: null,
seamless: USE_ATTRIBUTE | BOOLEAN_VALUE,
selected: USE_PROPERTY | BOOLEAN_VALUE,
shape: null,
size: USE_ATTRIBUTE | POSITIVE_NUMERIC_VALUE,
sizes: USE_ATTRIBUTE | SPACE_SEPARATED,
/* https://html.spec.whatwg.org/#attr-slot */
slot: null,
sortable: BOOLEAN_VALUE,
sorted: SPACE_SEPARATED,
span: POSITIVE_NUMERIC_VALUE,
spellCheck: null,
src: null,
srcDoc: USE_PROPERTY,
srcLang: null,
srcSet: USE_ATTRIBUTE | COMMA_SEPARATED,
start: NUMERIC_VALUE,
step: null,
style: null,
summary: null,
tabIndex: NUMERIC_VALUE,
target: null,
title: null,
translate: null,
type: null,
typeMustMatch: BOOLEAN_VALUE,
useMap: null,
value: USE_PROPERTY,
volume: POSITIVE_NUMERIC_VALUE,
width: USE_ATTRIBUTE | NUMERIC_VALUE,
wmode: USE_ATTRIBUTE,
wrap: null,
/*
* Non-standard Properties
*/
/* Non-standard Properties. */
/* autoCapitalize and autoCorrect are supported in
* Mobile Safari for keyboard hints. */
'autoCapitalize': null,
'autoCorrect': null,
/* autoSave allows WebKit/Blink to persist values of
* input fields on page reloads */
'autoSave': null,
/* itemProp, itemScope, itemType are for Microdata
* support. See http://schema.org/docs/gs.html */
'itemProp': USE_ATTRIBUTE | SPACE_SEPARATED,
'itemScope': USE_ATTRIBUTE | BOOLEAN_VALUE,
'itemType': USE_ATTRIBUTE | SPACE_SEPARATED,
/* itemID and itemRef are for Microdata support as well
* but only specified in the the WHATWG spec document.
* See https://html.spec.whatwg.org/multipage/
* microdata.html#microdata-dom-api
*/
'itemID': USE_ATTRIBUTE,
'itemRef': USE_ATTRIBUTE | SPACE_SEPARATED,
/* property is supported for OpenGraph in meta tags. */
'property': null,
/* results show looking glass icon and recent searches
* on input search fields in WebKit/Blink */
'results': null,
/* IE-only attribute that specifies security
* restrictions on an iframe as an alternative to the
* sandbox attribute on IE < 10 */
'security': USE_ATTRIBUTE,
/* IE-only attribute that controls focus behavior */
'unselectable': USE_ATTRIBUTE,
/* `autoCapitalize` and `autoCorrect` are supported in
* Mobile Safari for keyboard hints. */
autoCapitalize: null,
autoCorrect: null,
/* `autoSave` allows WebKit/Blink to persist values of
* input fields on page reloads */
autoSave: null,
/* `itemProp`, `itemScope`, `itemType` are for Microdata
* support. See http://schema.org/docs/gs.html */
itemProp: USE_ATTRIBUTE | SPACE_SEPARATED,
itemScope: USE_ATTRIBUTE | BOOLEAN_VALUE,
itemType: USE_ATTRIBUTE | SPACE_SEPARATED,
/* `itemID` and `itemRef` are for Microdata support as well
* but only specified in the the WHATWG spec document.
* See https://html.spec.whatwg.org/multipage/
* microdata.html#microdata-dom-api */
itemID: USE_ATTRIBUTE,
itemRef: USE_ATTRIBUTE | SPACE_SEPARATED,
/* `property` is supported for OpenGraph in meta tags. */
property: null,
/* `results` show looking glass icon and recent searches
* on input search fields in WebKit/Blink */
results: null,
/* IE-only attribute that specifies security
* restrictions on an iframe as an alternative to the
* sandbox attribute on IE < 10 */
security: USE_ATTRIBUTE,
/* IE-only attribute that controls focus behavior */
unselectable: USE_ATTRIBUTE,
/* Ancient. */
'xmlLang': USE_ATTRIBUTE,
'xmlBase': USE_ATTRIBUTE
/* Ancient. */
xmlLang: USE_ATTRIBUTE,
xmlBase: USE_ATTRIBUTE
};
/*
* Map of properties to attributes.
/* Map of properties to attributes.
* Names are lower-case properties.
* Values are HTML attributes.
*/
* Values are HTML attributes. */
var propertyToAttributeMapping = {
'xmlbase': 'xml:base',
'xmllang': 'xml:lang',
'classname': 'class',
'htmlfor': 'for',
'httpequiv': 'http-equiv',
'acceptcharset': 'accept-charset'
xmlbase: 'xml:base',
xmllang: 'xml:lang',
classname: 'class',
htmlfor: 'for',
httpequiv: 'http-equiv',
acceptcharset: 'accept-charset'
};
/*
* Expand config.
*/
/* Expand config. */
var information = {};

@@ -261,43 +225,38 @@ var property;

getPropertyInformation.all = information;
for (property in propertyConfig) {
name = lower(property);
name = propertyToAttributeMapping[name] || name;
config = propertyConfig[property];
name = lower(property);
name = propertyToAttributeMapping[name] || name;
config = propertyConfig[property];
information[name] = {
'name': name,
'propertyName': property,
'mustUseAttribute': check(config, USE_ATTRIBUTE),
'mustUseProperty': check(config, USE_PROPERTY),
'boolean': check(config, BOOLEAN_VALUE),
'overloadedBoolean': check(config, OVERLOADED_BOOLEAN_VALUE),
'numeric': check(config, NUMERIC_VALUE),
'positiveNumeric': check(config, POSITIVE_NUMERIC_VALUE),
'commaSeparated': check(config, COMMA_SEPARATED),
'spaceSeparated': check(config, SPACE_SEPARATED)
};
information[name] = {
name: name,
propertyName: property,
mustUseAttribute: check(config, USE_ATTRIBUTE),
mustUseProperty: check(config, USE_PROPERTY),
boolean: check(config, BOOLEAN_VALUE),
overloadedBoolean: check(config, OVERLOADED_BOOLEAN_VALUE),
numeric: check(config, NUMERIC_VALUE),
positiveNumeric: check(config, POSITIVE_NUMERIC_VALUE),
commaSeparated: check(config, COMMA_SEPARATED),
spaceSeparated: check(config, SPACE_SEPARATED)
};
}
/**
* Get a config for a property.
*
* @param {string} propertyName - Property name.
* @return {Object?} - Property config.
*/
/* Get a config for a property. */
function getPropertyInformation(propertyName) {
var insensitive = lower(propertyName);
var insensitive = lower(propertyName);
return information[propertyToAttributeMapping[insensitive] || insensitive];
return information[propertyToAttributeMapping[insensitive] || insensitive];
}
/*
* Expose raw access.
*/
/* Check a mask. */
function check(value, bitmask) {
return (value & bitmask) === bitmask;
}
getPropertyInformation.all = information;
/*
* Expose.
*/
module.exports = getPropertyInformation;
/* Lower-case a string. */
function lower(value) {
return value.toLowerCase();
}
{
"name": "property-information",
"version": "3.1.0",
"version": "3.2.0",
"description": "Information for HTML properties",

@@ -13,10 +13,3 @@ "license": "MIT",

],
"files": [
"index.js",
"LICENSE"
],
"repository": {
"type": "git",
"url": "https://github.com/wooorm/property-information.git"
},
"repository": "https://github.com/wooorm/property-information",
"bugs": "https://github.com/wooorm/property-information/issues",

@@ -27,29 +20,43 @@ "author": "Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)",

],
"files": [
"index.js"
],
"devDependencies": {
"browserify": "^13.0.0",
"eslint": "^2.0.0",
"browserify": "^14.0.0",
"esmangle": "^1.0.0",
"istanbul": "^0.4.0",
"jscs": "^2.0.0",
"jscs-jsdoc": "^1.0.0",
"remark": "^4.0.0",
"remark-comment-config": "^3.0.0",
"remark-github": "^4.0.1",
"remark-lint": "^3.0.0",
"remark-validate-links": "^3.0.0",
"remark-yaml-config": "^3.0.0",
"tape": "^4.2.0"
"nyc": "^11.0.0",
"remark-cli": "^3.0.0",
"remark-preset-wooorm": "^3.0.0",
"tape": "^4.2.0",
"xo": "^0.18.0"
},
"scripts": {
"build-md": "remark . --quiet --frail",
"build-md": "remark . -qfo",
"build-bundle": "browserify index.js --bare -s propertyInformation > property-information.js",
"build-mangle": "esmangle property-information.js > property-information.min.js",
"build": "npm run build-md && npm run build-bundle && npm run build-mangle",
"lint-api": "eslint .",
"lint-style": "jscs --reporter inline .",
"lint": "npm run lint-api && npm run lint-style",
"test-api": "node test.js",
"test-coverage": "istanbul cover test.js",
"lint": "xo",
"test-api": "node test",
"test-coverage": "nyc --reporter lcov tape test.js",
"test": "npm run build && npm run lint && npm run test-coverage"
},
"nyc": {
"check-coverage": true,
"lines": 100,
"functions": 100,
"branches": 100
},
"xo": {
"space": true,
"esnext": false,
"rules": {
"guard-for-in": "off"
},
"ignore": [
"property-information.js"
]
},
"remarkConfig": {
"plugins": ["preset-wooorm"]
}
}

@@ -13,9 +13,8 @@ # property-information [![Build Status][build-badge]][build-status] [![Coverage Status][coverage-badge]][coverage-status]

**property-information** is also available for AMD, CommonJS, and
globals ([uncompressed and compressed][releases]).
## Usage
```js
console.log(propertyInformation('class'));
var info = require('property-information');
console.log(info('class'));
```

@@ -44,14 +43,10 @@

Get information for a DOM property.
Get information for a DOM property by (case-insensitive) name.
Parameters:
Returns an [`Information`][information] object, if available.
* `name` (`string`) — Case-insensitive name.
Returns: [`Information?`][information] — Information, when available.
### `propertyInformation.all`
`Object` mapping case-insensitive names to [`Information`][information]
objects. This gives raw access to the information returned by
objects. This gives raw access to the information returned by
[`propertyInformation()`][property-information]: do not change the

@@ -62,36 +57,28 @@ objects.

Properties:
`Object`:
* `name` (`string`) — Case-insensitive name;
* `name` (`string`)
— Case-insensitive name
* `propertyName` (`string`)
— Case-sensitive IDL attribute (e.g., a `class` attribute is added in HTML
and a `className` is added in Web IDL);
and a `className` is added in Web IDL)
* `mustUseAttribute` (`boolean`)
— Whether `setAttribute` must be used when patching a DOM node;
— Whether `setAttribute` must be used when patching a DOM node
* `mustUseProperty` (`boolean`)
— Whether `node[propertyName]` must be used when patching a DOM node;
— Whether `node[propertyName]` must be used when patching a DOM node
* `boolean` (`boolean`)
— Whether the value of the property is `boolean`;
— Whether the value of the property is `boolean`
* `overloadedBoolean` (`boolean`)
— Whether the value of the property can be `boolean`;
— Whether the value of the property can be `boolean`
* `numeric` (`boolean`)
— Whether the value of the property is `number`;
— Whether the value of the property is `number`
* `positiveNumeric` (`boolean`)
— Whether the value of the property is `number` and positive;
— Whether the value of the property is `number` and positive
* `spaceSeparated` (`boolean`)
— Whether the value of the property is a [space-separated][] list;
— Whether the value of the property is a [space-separated][] list
* `commaSeparated` (`boolean`)
— Whether the value of the property is a [comma-separated][] list.
— Whether the value of the property is a [comma-separated][] list
Note that some values can be both `*Separated` _and_ a primitive, in that case
each of the tokens should be regarded as a primitive. For example, `itemScope`
each of the tokens should be regarded as a primitive. For example, `itemScope`
is both `spaceSeparated` and `boolean`:

@@ -133,4 +120,2 @@

[releases]: https://github.com/wooorm/property-information/releases
[license]: LICENSE

@@ -137,0 +122,0 @@

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc