react-property
Advanced tools
Comparing version 2.0.1 to 2.0.2
656
lib/index.js
'use strict'; | ||
function _iterableToArrayLimit(r, l) { | ||
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; | ||
if (null != t) { | ||
var e, | ||
n, | ||
i, | ||
u, | ||
a = [], | ||
f = !0, | ||
o = !1; | ||
try { | ||
if (i = (t = t.call(r)).next, 0 === l) { | ||
if (Object(t) !== t) return; | ||
f = !1; | ||
} else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); | ||
} catch (r) { | ||
o = !0, n = r; | ||
} finally { | ||
try { | ||
if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; | ||
} finally { | ||
if (o) throw n; | ||
} | ||
} | ||
return a; | ||
} | ||
} | ||
function _slicedToArray(arr, i) { | ||
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); | ||
} | ||
function _arrayWithHoles(arr) { | ||
if (Array.isArray(arr)) return arr; | ||
} | ||
function _unsupportedIterableToArray(o, minLen) { | ||
if (!o) return; | ||
if (typeof o === "string") return _arrayLikeToArray(o, minLen); | ||
var n = Object.prototype.toString.call(o).slice(8, -1); | ||
if (n === "Object" && o.constructor) n = o.constructor.name; | ||
if (n === "Map" || n === "Set") return Array.from(o); | ||
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); | ||
} | ||
function _arrayLikeToArray(arr, len) { | ||
if (len == null || len > arr.length) len = arr.length; | ||
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; | ||
return arr2; | ||
} | ||
function _nonIterableRest() { | ||
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); | ||
} | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* | ||
*/ | ||
// A reserved attribute. | ||
// It is handled by React separately and shouldn't be written to the DOM. | ||
var RESERVED = 0; | ||
const RESERVED = 0; | ||
// A simple string attribute. | ||
// Attributes that aren't in the filter are presumed to have this type. | ||
var STRING = 1; | ||
const STRING = 1; | ||
@@ -65,3 +27,3 @@ // A string attribute that accepts booleans in React. In HTML, these are called | ||
// When false, it should be set to a "false" string. | ||
var BOOLEANISH_STRING = 2; | ||
const BOOLEANISH_STRING = 2; | ||
@@ -71,3 +33,3 @@ // A real boolean attribute. | ||
// When false, it should be omitted. | ||
var BOOLEAN = 3; | ||
const BOOLEAN = 3; | ||
@@ -78,16 +40,29 @@ // An attribute that can be used as a flag as well as with a value. | ||
// For any other value, should be present with that value. | ||
var OVERLOADED_BOOLEAN = 4; | ||
const OVERLOADED_BOOLEAN = 4; | ||
// An attribute that must be numeric or parse as a numeric. | ||
// When falsy, it should be removed. | ||
var NUMERIC = 5; | ||
const NUMERIC = 5; | ||
// An attribute that must be positive numeric or parse as a positive numeric. | ||
// When falsy, it should be removed. | ||
var POSITIVE_NUMERIC = 6; | ||
const POSITIVE_NUMERIC = 6; | ||
function getPropertyInfo(name) { | ||
return properties.hasOwnProperty(name) ? properties[name] : null; | ||
} | ||
function PropertyInfoRecord(name, type, mustUseProperty, attributeName, attributeNamespace, sanitizeURL, removeEmptyString) { | ||
this.acceptsBooleans = type === BOOLEANISH_STRING || type === BOOLEAN || type === OVERLOADED_BOOLEAN; | ||
function PropertyInfoRecord( | ||
name, | ||
type, | ||
mustUseProperty, | ||
attributeName, | ||
attributeNamespace, | ||
sanitizeURL, | ||
removeEmptyString, | ||
) { | ||
this.acceptsBooleans = | ||
type === BOOLEANISH_STRING || | ||
type === BOOLEAN || | ||
type === OVERLOADED_BOOLEAN; | ||
this.attributeName = attributeName; | ||
@@ -105,21 +80,29 @@ this.attributeNamespace = attributeNamespace; | ||
// name warnings. | ||
var properties = {}; | ||
const properties = {}; | ||
// These props are reserved by React. They shouldn't be written to the DOM. | ||
var reservedProps = ['children', 'dangerouslySetInnerHTML', | ||
// TODO: This prevents the assignment of defaultValue to regular | ||
// elements (not just inputs). Now that ReactDOMInput assigns to the | ||
// defaultValue property -- do we need this? | ||
'defaultValue', 'defaultChecked', 'innerHTML', 'suppressContentEditableWarning', 'suppressHydrationWarning', 'style']; | ||
reservedProps.forEach(function (name) { | ||
properties[name] = new PropertyInfoRecord(name, RESERVED, false, | ||
// mustUseProperty | ||
name, | ||
// attributeName | ||
null, | ||
// attributeNamespace | ||
false, | ||
// sanitizeURL | ||
false) // removeEmptyString | ||
; | ||
const reservedProps = [ | ||
'children', | ||
'dangerouslySetInnerHTML', | ||
// TODO: This prevents the assignment of defaultValue to regular | ||
// elements (not just inputs). Now that ReactDOMInput assigns to the | ||
// defaultValue property -- do we need this? | ||
'defaultValue', | ||
'defaultChecked', | ||
'innerHTML', | ||
'suppressContentEditableWarning', | ||
'suppressHydrationWarning', | ||
'style', | ||
]; | ||
reservedProps.forEach(name => { | ||
properties[name] = new PropertyInfoRecord( | ||
name, | ||
RESERVED, | ||
false, // mustUseProperty | ||
name, // attributeName | ||
null, // attributeNamespace | ||
false, // sanitizeURL | ||
false, // removeEmptyString | ||
); | ||
}); | ||
@@ -129,16 +112,17 @@ | ||
// This is a mapping from React prop names to the attribute names. | ||
[['acceptCharset', 'accept-charset'], ['className', 'class'], ['htmlFor', 'for'], ['httpEquiv', 'http-equiv']].forEach(function (_ref) { | ||
var _ref2 = _slicedToArray(_ref, 2), | ||
name = _ref2[0], | ||
attributeName = _ref2[1]; | ||
properties[name] = new PropertyInfoRecord(name, STRING, false, | ||
// mustUseProperty | ||
attributeName, | ||
// attributeName | ||
null, | ||
// attributeNamespace | ||
false, | ||
// sanitizeURL | ||
false) // removeEmptyString | ||
; | ||
[ | ||
['acceptCharset', 'accept-charset'], | ||
['className', 'class'], | ||
['htmlFor', 'for'], | ||
['httpEquiv', 'http-equiv'], | ||
].forEach(([name, attributeName]) => { | ||
properties[name] = new PropertyInfoRecord( | ||
name, | ||
STRING, | ||
false, // mustUseProperty | ||
attributeName, // attributeName | ||
null, // attributeNamespace | ||
false, // sanitizeURL | ||
false, // removeEmptyString | ||
); | ||
}); | ||
@@ -149,13 +133,12 @@ | ||
// these aren't boolean attributes (they are coerced to strings). | ||
['contentEditable', 'draggable', 'spellCheck', 'value'].forEach(function (name) { | ||
properties[name] = new PropertyInfoRecord(name, BOOLEANISH_STRING, false, | ||
// mustUseProperty | ||
name.toLowerCase(), | ||
// attributeName | ||
null, | ||
// attributeNamespace | ||
false, | ||
// sanitizeURL | ||
false) // removeEmptyString | ||
; | ||
['contentEditable', 'draggable', 'spellCheck', 'value'].forEach(name => { | ||
properties[name] = new PropertyInfoRecord( | ||
name, | ||
BOOLEANISH_STRING, | ||
false, // mustUseProperty | ||
name.toLowerCase(), // attributeName | ||
null, // attributeNamespace | ||
false, // sanitizeURL | ||
false, // removeEmptyString | ||
); | ||
}); | ||
@@ -167,32 +150,57 @@ | ||
// Since these are SVG attributes, their attribute names are case-sensitive. | ||
['autoReverse', 'externalResourcesRequired', 'focusable', 'preserveAlpha'].forEach(function (name) { | ||
properties[name] = new PropertyInfoRecord(name, BOOLEANISH_STRING, false, | ||
// mustUseProperty | ||
name, | ||
// attributeName | ||
null, | ||
// attributeNamespace | ||
false, | ||
// sanitizeURL | ||
false) // removeEmptyString | ||
; | ||
[ | ||
'autoReverse', | ||
'externalResourcesRequired', | ||
'focusable', | ||
'preserveAlpha', | ||
].forEach(name => { | ||
properties[name] = new PropertyInfoRecord( | ||
name, | ||
BOOLEANISH_STRING, | ||
false, // mustUseProperty | ||
name, // attributeName | ||
null, // attributeNamespace | ||
false, // sanitizeURL | ||
false, // removeEmptyString | ||
); | ||
}); | ||
// These are HTML boolean attributes. | ||
['allowFullScreen', 'async', | ||
// Note: there is a special case that prevents it from being written to the DOM | ||
// on the client side because the browsers are inconsistent. Instead we call focus(). | ||
'autoFocus', 'autoPlay', 'controls', 'default', 'defer', 'disabled', 'disablePictureInPicture', 'disableRemotePlayback', 'formNoValidate', 'hidden', 'loop', 'noModule', 'noValidate', 'open', 'playsInline', 'readOnly', 'required', 'reversed', 'scoped', 'seamless', | ||
// Microdata | ||
'itemScope'].forEach(function (name) { | ||
properties[name] = new PropertyInfoRecord(name, BOOLEAN, false, | ||
// mustUseProperty | ||
name.toLowerCase(), | ||
// attributeName | ||
null, | ||
// attributeNamespace | ||
false, | ||
// sanitizeURL | ||
false) // removeEmptyString | ||
; | ||
[ | ||
'allowFullScreen', | ||
'async', | ||
// Note: there is a special case that prevents it from being written to the DOM | ||
// on the client side because the browsers are inconsistent. Instead we call focus(). | ||
'autoFocus', | ||
'autoPlay', | ||
'controls', | ||
'default', | ||
'defer', | ||
'disabled', | ||
'disablePictureInPicture', | ||
'disableRemotePlayback', | ||
'formNoValidate', | ||
'hidden', | ||
'loop', | ||
'noModule', | ||
'noValidate', | ||
'open', | ||
'playsInline', | ||
'readOnly', | ||
'required', | ||
'reversed', | ||
'scoped', | ||
'seamless', | ||
// Microdata | ||
'itemScope', | ||
].forEach(name => { | ||
properties[name] = new PropertyInfoRecord( | ||
name, | ||
BOOLEAN, | ||
false, // mustUseProperty | ||
name.toLowerCase(), // attributeName | ||
null, // attributeNamespace | ||
false, // sanitizeURL | ||
false, // removeEmptyString | ||
); | ||
}); | ||
@@ -202,21 +210,23 @@ | ||
// rather than attributes. These are all booleans. | ||
['checked', | ||
// Note: `option.selected` is not updated if `select.multiple` is | ||
// disabled with `removeAttribute`. We have special logic for handling this. | ||
'multiple', 'muted', 'selected' | ||
[ | ||
'checked', | ||
// Note: `option.selected` is not updated if `select.multiple` is | ||
// disabled with `removeAttribute`. We have special logic for handling this. | ||
'multiple', | ||
'muted', | ||
'selected', | ||
// NOTE: if you add a camelCased prop to this list, | ||
// you'll need to set attributeName to name.toLowerCase() | ||
// instead in the assignment below. | ||
].forEach(function (name) { | ||
properties[name] = new PropertyInfoRecord(name, BOOLEAN, true, | ||
// mustUseProperty | ||
name, | ||
// attributeName | ||
null, | ||
// attributeNamespace | ||
false, | ||
// sanitizeURL | ||
false) // removeEmptyString | ||
; | ||
// NOTE: if you add a camelCased prop to this list, | ||
// you'll need to set attributeName to name.toLowerCase() | ||
// instead in the assignment below. | ||
].forEach(name => { | ||
properties[name] = new PropertyInfoRecord( | ||
name, | ||
BOOLEAN, | ||
true, // mustUseProperty | ||
name, // attributeName | ||
null, // attributeNamespace | ||
false, // sanitizeURL | ||
false, // removeEmptyString | ||
); | ||
}); | ||
@@ -226,57 +236,58 @@ | ||
// booleans, but can also accept a string value. | ||
['capture', 'download' | ||
[ | ||
'capture', | ||
'download', | ||
// NOTE: if you add a camelCased prop to this list, | ||
// you'll need to set attributeName to name.toLowerCase() | ||
// instead in the assignment below. | ||
].forEach(function (name) { | ||
properties[name] = new PropertyInfoRecord(name, OVERLOADED_BOOLEAN, false, | ||
// mustUseProperty | ||
name, | ||
// attributeName | ||
null, | ||
// attributeNamespace | ||
false, | ||
// sanitizeURL | ||
false) // removeEmptyString | ||
; | ||
// NOTE: if you add a camelCased prop to this list, | ||
// you'll need to set attributeName to name.toLowerCase() | ||
// instead in the assignment below. | ||
].forEach(name => { | ||
properties[name] = new PropertyInfoRecord( | ||
name, | ||
OVERLOADED_BOOLEAN, | ||
false, // mustUseProperty | ||
name, // attributeName | ||
null, // attributeNamespace | ||
false, // sanitizeURL | ||
false, // removeEmptyString | ||
); | ||
}); | ||
// These are HTML attributes that must be positive numbers. | ||
['cols', 'rows', 'size', 'span' | ||
[ | ||
'cols', | ||
'rows', | ||
'size', | ||
'span', | ||
// NOTE: if you add a camelCased prop to this list, | ||
// you'll need to set attributeName to name.toLowerCase() | ||
// instead in the assignment below. | ||
].forEach(function (name) { | ||
properties[name] = new PropertyInfoRecord(name, POSITIVE_NUMERIC, false, | ||
// mustUseProperty | ||
name, | ||
// attributeName | ||
null, | ||
// attributeNamespace | ||
false, | ||
// sanitizeURL | ||
false) // removeEmptyString | ||
; | ||
// NOTE: if you add a camelCased prop to this list, | ||
// you'll need to set attributeName to name.toLowerCase() | ||
// instead in the assignment below. | ||
].forEach(name => { | ||
properties[name] = new PropertyInfoRecord( | ||
name, | ||
POSITIVE_NUMERIC, | ||
false, // mustUseProperty | ||
name, // attributeName | ||
null, // attributeNamespace | ||
false, // sanitizeURL | ||
false, // removeEmptyString | ||
); | ||
}); | ||
// These are HTML attributes that must be numbers. | ||
['rowSpan', 'start'].forEach(function (name) { | ||
properties[name] = new PropertyInfoRecord(name, NUMERIC, false, | ||
// mustUseProperty | ||
name.toLowerCase(), | ||
// attributeName | ||
null, | ||
// attributeNamespace | ||
false, | ||
// sanitizeURL | ||
false) // removeEmptyString | ||
; | ||
['rowSpan', 'start'].forEach(name => { | ||
properties[name] = new PropertyInfoRecord( | ||
name, | ||
NUMERIC, | ||
false, // mustUseProperty | ||
name.toLowerCase(), // attributeName | ||
null, // attributeNamespace | ||
false, // sanitizeURL | ||
false, // removeEmptyString | ||
); | ||
}); | ||
var CAMELIZE = /[\-\:]([a-z])/g; | ||
var capitalize = function capitalize(token) { | ||
return token[1].toUpperCase(); | ||
}; | ||
const CAMELIZE = /[\-\:]([a-z])/g; | ||
const capitalize = token => token[1].toUpperCase(); | ||
@@ -288,49 +299,138 @@ // This is a list of all SVG attributes that need special casing, namespacing, | ||
// scraping the MDN documentation. | ||
['accent-height', 'alignment-baseline', 'arabic-form', 'baseline-shift', 'cap-height', 'clip-path', 'clip-rule', 'color-interpolation', 'color-interpolation-filters', 'color-profile', 'color-rendering', 'dominant-baseline', 'enable-background', 'fill-opacity', 'fill-rule', 'flood-color', 'flood-opacity', 'font-family', 'font-size', 'font-size-adjust', 'font-stretch', 'font-style', 'font-variant', 'font-weight', 'glyph-name', 'glyph-orientation-horizontal', 'glyph-orientation-vertical', 'horiz-adv-x', 'horiz-origin-x', 'image-rendering', 'letter-spacing', 'lighting-color', 'marker-end', 'marker-mid', 'marker-start', 'overline-position', 'overline-thickness', 'paint-order', 'panose-1', 'pointer-events', 'rendering-intent', 'shape-rendering', 'stop-color', 'stop-opacity', 'strikethrough-position', 'strikethrough-thickness', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke-width', 'text-anchor', 'text-decoration', 'text-rendering', 'underline-position', 'underline-thickness', 'unicode-bidi', 'unicode-range', 'units-per-em', 'v-alphabetic', 'v-hanging', 'v-ideographic', 'v-mathematical', 'vector-effect', 'vert-adv-y', 'vert-origin-x', 'vert-origin-y', 'word-spacing', 'writing-mode', 'xmlns:xlink', 'x-height' | ||
[ | ||
'accent-height', | ||
'alignment-baseline', | ||
'arabic-form', | ||
'baseline-shift', | ||
'cap-height', | ||
'clip-path', | ||
'clip-rule', | ||
'color-interpolation', | ||
'color-interpolation-filters', | ||
'color-profile', | ||
'color-rendering', | ||
'dominant-baseline', | ||
'enable-background', | ||
'fill-opacity', | ||
'fill-rule', | ||
'flood-color', | ||
'flood-opacity', | ||
'font-family', | ||
'font-size', | ||
'font-size-adjust', | ||
'font-stretch', | ||
'font-style', | ||
'font-variant', | ||
'font-weight', | ||
'glyph-name', | ||
'glyph-orientation-horizontal', | ||
'glyph-orientation-vertical', | ||
'horiz-adv-x', | ||
'horiz-origin-x', | ||
'image-rendering', | ||
'letter-spacing', | ||
'lighting-color', | ||
'marker-end', | ||
'marker-mid', | ||
'marker-start', | ||
'overline-position', | ||
'overline-thickness', | ||
'paint-order', | ||
'panose-1', | ||
'pointer-events', | ||
'rendering-intent', | ||
'shape-rendering', | ||
'stop-color', | ||
'stop-opacity', | ||
'strikethrough-position', | ||
'strikethrough-thickness', | ||
'stroke-dasharray', | ||
'stroke-dashoffset', | ||
'stroke-linecap', | ||
'stroke-linejoin', | ||
'stroke-miterlimit', | ||
'stroke-opacity', | ||
'stroke-width', | ||
'text-anchor', | ||
'text-decoration', | ||
'text-rendering', | ||
'underline-position', | ||
'underline-thickness', | ||
'unicode-bidi', | ||
'unicode-range', | ||
'units-per-em', | ||
'v-alphabetic', | ||
'v-hanging', | ||
'v-ideographic', | ||
'v-mathematical', | ||
'vector-effect', | ||
'vert-adv-y', | ||
'vert-origin-x', | ||
'vert-origin-y', | ||
'word-spacing', | ||
'writing-mode', | ||
'xmlns:xlink', | ||
'x-height', | ||
// NOTE: if you add a camelCased prop to this list, | ||
// you'll need to set attributeName to name.toLowerCase() | ||
// instead in the assignment below. | ||
].forEach(function (attributeName) { | ||
var name = attributeName.replace(CAMELIZE, capitalize); | ||
properties[name] = new PropertyInfoRecord(name, STRING, false, | ||
// mustUseProperty | ||
attributeName, null, | ||
// attributeNamespace | ||
false, | ||
// sanitizeURL | ||
false) // removeEmptyString | ||
; | ||
// NOTE: if you add a camelCased prop to this list, | ||
// you'll need to set attributeName to name.toLowerCase() | ||
// instead in the assignment below. | ||
].forEach(attributeName => { | ||
const name = attributeName.replace(CAMELIZE, capitalize); | ||
properties[name] = new PropertyInfoRecord( | ||
name, | ||
STRING, | ||
false, // mustUseProperty | ||
attributeName, | ||
null, // attributeNamespace | ||
false, // sanitizeURL | ||
false, // removeEmptyString | ||
); | ||
}); | ||
// String SVG attributes with the xlink namespace. | ||
['xlink:actuate', 'xlink:arcrole', 'xlink:role', 'xlink:show', 'xlink:title', 'xlink:type' | ||
[ | ||
'xlink:actuate', | ||
'xlink:arcrole', | ||
'xlink:role', | ||
'xlink:show', | ||
'xlink:title', | ||
'xlink:type', | ||
// NOTE: if you add a camelCased prop to this list, | ||
// you'll need to set attributeName to name.toLowerCase() | ||
// instead in the assignment below. | ||
].forEach(function (attributeName) { | ||
var name = attributeName.replace(CAMELIZE, capitalize); | ||
properties[name] = new PropertyInfoRecord(name, STRING, false, | ||
// mustUseProperty | ||
attributeName, 'http://www.w3.org/1999/xlink', false, | ||
// sanitizeURL | ||
false) // removeEmptyString | ||
; | ||
// NOTE: if you add a camelCased prop to this list, | ||
// you'll need to set attributeName to name.toLowerCase() | ||
// instead in the assignment below. | ||
].forEach(attributeName => { | ||
const name = attributeName.replace(CAMELIZE, capitalize); | ||
properties[name] = new PropertyInfoRecord( | ||
name, | ||
STRING, | ||
false, // mustUseProperty | ||
attributeName, | ||
'http://www.w3.org/1999/xlink', | ||
false, // sanitizeURL | ||
false, // removeEmptyString | ||
); | ||
}); | ||
// String SVG attributes with the xml namespace. | ||
['xml:base', 'xml:lang', 'xml:space' | ||
[ | ||
'xml:base', | ||
'xml:lang', | ||
'xml:space', | ||
// NOTE: if you add a camelCased prop to this list, | ||
// you'll need to set attributeName to name.toLowerCase() | ||
// instead in the assignment below. | ||
].forEach(function (attributeName) { | ||
var name = attributeName.replace(CAMELIZE, capitalize); | ||
properties[name] = new PropertyInfoRecord(name, STRING, false, | ||
// mustUseProperty | ||
attributeName, 'http://www.w3.org/XML/1998/namespace', false, | ||
// sanitizeURL | ||
false) // removeEmptyString | ||
; | ||
// NOTE: if you add a camelCased prop to this list, | ||
// you'll need to set attributeName to name.toLowerCase() | ||
// instead in the assignment below. | ||
].forEach(attributeName => { | ||
const name = attributeName.replace(CAMELIZE, capitalize); | ||
properties[name] = new PropertyInfoRecord( | ||
name, | ||
STRING, | ||
false, // mustUseProperty | ||
attributeName, | ||
'http://www.w3.org/XML/1998/namespace', | ||
false, // sanitizeURL | ||
false, // removeEmptyString | ||
); | ||
}); | ||
@@ -341,13 +441,12 @@ | ||
// the React name like we do for attributes that exist only in HTML. | ||
['tabIndex', 'crossOrigin'].forEach(function (attributeName) { | ||
properties[attributeName] = new PropertyInfoRecord(attributeName, STRING, false, | ||
// mustUseProperty | ||
attributeName.toLowerCase(), | ||
// attributeName | ||
null, | ||
// attributeNamespace | ||
false, | ||
// sanitizeURL | ||
false) // removeEmptyString | ||
; | ||
['tabIndex', 'crossOrigin'].forEach(attributeName => { | ||
properties[attributeName] = new PropertyInfoRecord( | ||
attributeName, | ||
STRING, | ||
false, // mustUseProperty | ||
attributeName.toLowerCase(), // attributeName | ||
null, // attributeNamespace | ||
false, // sanitizeURL | ||
false, // removeEmptyString | ||
); | ||
}); | ||
@@ -357,43 +456,58 @@ | ||
// These will also need to accept Trusted Types object in the future. | ||
var xlinkHref = 'xlinkHref'; | ||
properties[xlinkHref] = new PropertyInfoRecord('xlinkHref', STRING, false, | ||
// mustUseProperty | ||
'xlink:href', 'http://www.w3.org/1999/xlink', true, | ||
// sanitizeURL | ||
false) // removeEmptyString | ||
; | ||
const xlinkHref = 'xlinkHref'; | ||
properties[xlinkHref] = new PropertyInfoRecord( | ||
'xlinkHref', | ||
STRING, | ||
false, // mustUseProperty | ||
'xlink:href', | ||
'http://www.w3.org/1999/xlink', | ||
true, // sanitizeURL | ||
false, // removeEmptyString | ||
); | ||
['src', 'href', 'action', 'formAction'].forEach(function (attributeName) { | ||
properties[attributeName] = new PropertyInfoRecord(attributeName, STRING, false, | ||
// mustUseProperty | ||
attributeName.toLowerCase(), | ||
// attributeName | ||
null, | ||
// attributeNamespace | ||
true, | ||
// sanitizeURL | ||
true) // removeEmptyString | ||
; | ||
['src', 'href', 'action', 'formAction'].forEach(attributeName => { | ||
properties[attributeName] = new PropertyInfoRecord( | ||
attributeName, | ||
STRING, | ||
false, // mustUseProperty | ||
attributeName.toLowerCase(), // attributeName | ||
null, // attributeNamespace | ||
true, // sanitizeURL | ||
true, // removeEmptyString | ||
); | ||
}); | ||
var _require = require('../lib/possibleStandardNamesOptimized'), | ||
CAMELCASE = _require.CAMELCASE, | ||
SAME = _require.SAME, | ||
possibleStandardNamesOptimized = _require.possibleStandardNames; | ||
var ATTRIBUTE_NAME_START_CHAR = ":A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD"; | ||
var ATTRIBUTE_NAME_CHAR = ATTRIBUTE_NAME_START_CHAR + "\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040"; | ||
// | ||
const { | ||
CAMELCASE, | ||
SAME, | ||
possibleStandardNames: possibleStandardNamesOptimized | ||
} = require('../lib/possibleStandardNamesOptimized'); | ||
const ATTRIBUTE_NAME_START_CHAR = | ||
':A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD'; | ||
const ATTRIBUTE_NAME_CHAR = | ||
ATTRIBUTE_NAME_START_CHAR + '\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040'; | ||
/** | ||
* Checks whether a property name is a custom attribute. | ||
* | ||
* @see {@link https://github.com/facebook/react/blob/15-stable/src/renderers/dom/shared/HTMLDOMPropertyConfig.js#L23-L25} | ||
* @see https://github.com/facebook/react/blob/15-stable/src/renderers/dom/shared/HTMLDOMPropertyConfig.js#L23-L25 | ||
* | ||
* @param {string} | ||
* @return {boolean} | ||
* @type {(attribute: string) => boolean} | ||
*/ | ||
var isCustomAttribute = RegExp.prototype.test.bind( | ||
// eslint-disable-next-line no-misleading-character-class | ||
new RegExp('^(data|aria)-[' + ATTRIBUTE_NAME_CHAR + ']*$')); | ||
var possibleStandardNames = Object.keys(possibleStandardNamesOptimized).reduce(function (accumulator, standardName) { | ||
var propName = possibleStandardNamesOptimized[standardName]; | ||
const isCustomAttribute = | ||
RegExp.prototype.test.bind( | ||
// eslint-disable-next-line no-misleading-character-class | ||
new RegExp('^(data|aria)-[' + ATTRIBUTE_NAME_CHAR + ']*$') | ||
); | ||
/** | ||
* @type {Record<string, string>} | ||
*/ | ||
const possibleStandardNames = Object.keys( | ||
possibleStandardNamesOptimized | ||
).reduce((accumulator, standardName) => { | ||
const propName = possibleStandardNamesOptimized[standardName]; | ||
if (propName === SAME) { | ||
@@ -400,0 +514,0 @@ accumulator[standardName] = standardName; |
@@ -13,3 +13,3 @@ 'use strict'; | ||
// warnings. | ||
var possibleStandardNames = { | ||
const possibleStandardNames = { | ||
// HTML | ||
@@ -39,3 +39,3 @@ accept: 'accept', | ||
cite: 'cite', | ||
"class": 'className', | ||
class: 'className', | ||
classid: 'classID', | ||
@@ -55,3 +55,3 @@ classname: 'className', | ||
datetime: 'dateTime', | ||
"default": 'default', | ||
default: 'default', | ||
defaultchecked: 'defaultChecked', | ||
@@ -68,3 +68,3 @@ defaultvalue: 'defaultValue', | ||
enterkeyhint: 'enterKeyHint', | ||
"for": 'htmlFor', | ||
for: 'htmlFor', | ||
form: 'form', | ||
@@ -166,2 +166,3 @@ formmethod: 'formMethod', | ||
wrap: 'wrap', | ||
// SVG | ||
@@ -287,3 +288,3 @@ about: 'about', | ||
in2: 'in2', | ||
"in": 'in', | ||
in: 'in', | ||
inlist: 'inlist', | ||
@@ -428,3 +429,3 @@ intercept: 'intercept', | ||
transform: 'transform', | ||
"typeof": 'typeof', | ||
typeof: 'typeof', | ||
u1: 'u1', | ||
@@ -505,5 +506,5 @@ u2: 'u2', | ||
z: 'z', | ||
zoomandpan: 'zoomAndPan' | ||
zoomandpan: 'zoomAndPan', | ||
}; | ||
module.exports = possibleStandardNames; |
{ | ||
"name": "react-property", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"description": "HTML and SVG DOM property configs used by React.", | ||
"main": "lib/index.js", | ||
"scripts": { | ||
"build": "rollup -c rollup.config.possibleStandardNames.mjs && scripts/build.js && rollup -c", | ||
"build": "npm run clean && rollup -c rollup.config.possibleStandardNames.mjs && scripts/build.js && rollup -c && tsc lib/*.js --declaration --allowJs --emitDeclarationOnly", | ||
"clean": "rm -rf lib", | ||
"lint": "eslint --ignore-path .gitignore .", | ||
"lint:fix": "npm run lint -- --fix", | ||
"prepublishOnly": "npm run lint && npm run clean && npm run build && npm test", | ||
"prepublishOnly": "npm run lint && npm run build && npm test", | ||
"test": "jest --coverage --ci", | ||
@@ -37,14 +37,15 @@ "test:watch": "jest --watch" | ||
"devDependencies": { | ||
"@babel/preset-env": "7.23.2", | ||
"@babel/preset-flow": "7.22.15", | ||
"@rollup/plugin-alias": "5.0.1", | ||
"@rollup/plugin-babel": "6.0.4", | ||
"@rollup/plugin-sucrase": "5.0.2", | ||
"eslint": "8.52.0", | ||
"eslint-plugin-ft-flow": "3.0.1", | ||
"eslint-plugin-prettier": "5.0.1", | ||
"hermes-eslint": "0.17.0", | ||
"jest": "29.7.0", | ||
"prettier": "3.0.3", | ||
"rollup": "4.1.4" | ||
"rollup": "4.1.4", | ||
"typescript": "5.2.2" | ||
}, | ||
"license": "MIT", | ||
"gitHead": "907833dc2d968d1a7150a2da5efc646bad128f1f" | ||
"gitHead": "c4199877ca3b349fef669a7315ca4efcdab45a76" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
64415
8
2473
10