Skip to content

Commit 4213cbd

Browse files
feat(react-property): add module that exports isCustomAttribute
1 parent f6ee4df commit 4213cbd

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
var ATTRIBUTE_NAME_START_CHAR =
2+
':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';
3+
4+
var ATTRIBUTE_NAME_CHAR =
5+
ATTRIBUTE_NAME_START_CHAR + '\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040';
6+
7+
/**
8+
* Checks whether a property name is a custom attribute.
9+
*
10+
* @see https://github.com/facebook/react/blob/15-stable/src/renderers/dom/shared/HTMLDOMPropertyConfig.js#L23-L25
11+
*
12+
* @param {String}
13+
* @return {Boolean}
14+
*/
15+
var isCustomAttribute = RegExp.prototype.test.bind(
16+
new RegExp('^(data|aria)-[' + ATTRIBUTE_NAME_CHAR + ']*$')
17+
);
18+
19+
module.exports = isCustomAttribute;

0 commit comments

Comments
 (0)