luhn-generator
Version:
A generator of numbers that passes the validation of Luhn algorithm or Luhn formula, also known as the 'modulus 10' or 'mod 10' algorithm
38 lines (31 loc) • 760 B
JavaScript
import { isXHTML } from '../../core/utils';
function hasValue(value) {
return (value || '').trim() !== '';
}
function hasLangEvaluate(node, options, virtualNode) {
// special case when xml:lang has a value and lang does not
// but the document is not XHTML
if (
options.attributes.includes('xml:lang') &&
options.attributes.includes('lang') &&
hasValue(virtualNode.attr('xml:lang')) &&
!hasValue(virtualNode.attr('lang')) &&
!isXHTML(document)
) {
this.data({
messageKey: 'noXHTML'
});
return false;
}
const hasLang = options.attributes.some(name => {
return hasValue(virtualNode.attr(name));
});
if (!hasLang) {
this.data({
messageKey: 'noLang'
});
return false;
}
return true;
}
export default hasLangEvaluate;