You're Invited: Meet the Socket team at BSidesSF and RSAC - April 27 - May 1.RSVP
Socket
Sign inDemoInstall
Socket

aria-label-prop-type

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aria-label-prop-type - npm Package Compare versions

Comparing version

to
1.1.1

83

index.js

@@ -1,84 +0,5 @@

var React = require('react');
var accessibilityLabel;
if (process.env.NODE_ENV !== 'production') {
// development:
var deepTraverseChildren = function(children, callback) {
React.Children.forEach(children, function(child) {
if (!child) {
return;
}
callback(child);
if (child.props && child.props.children) {
deepTraverseChildren(child.props.children, callback);
}
});
};
var _accessibilityLabel = function(
props,
propName,
componentName,
renderPropDefault
) {
var label = props[propName];
if (typeof label === 'string' && label.trim() !== '') {
return;
}
var hasStringChild = false;
var children =
typeof props.children === 'function'
? props.children(renderPropDefault)
: props.children;
deepTraverseChildren(children, function(child) {
if (typeof child === 'string') {
hasStringChild = true;
}
});
if (hasStringChild) {
return;
}
return new Error(
'`' +
componentName +
'` must have either an `' +
propName +
'` prop, or one or more text (string) children ' +
'for screen-reader accessibility.'
);
};
accessibilityLabel = function(props, propName, componentName) {
return _accessibilityLabel(props, propName, componentName);
};
accessibilityLabel.isRequired = accessibilityLabel;
accessibilityLabel.renderPropDefault = function(renderPropDefault) {
var propType = function(props, propName, componentName) {
return _accessibilityLabel(
props,
propName,
componentName,
renderPropDefault
);
};
propType.isRequired = propType;
return propType;
};
module.exports = require('./aria-label-prop-type.dev.js');
} else {
// production:
accessibilityLabel = function() {};
accessibilityLabel.isRequired = accessibilityLabel;
accessibilityLabel.renderPropDefault = function() {
return accessibilityLabel;
};
module.exports = require('./aria-label-prop-type.prod.js');
}
module.exports = accessibilityLabel;

2

package.json
{
"name": "aria-label-prop-type",
"version": "1.1.0",
"version": "1.1.1",
"description": "A prop type for aria-label and accessibilityLabel that accepts either a string, or a string child somewhere in children",

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