xml-lang-mismatch-matches.js 605 B

1234567891011121314
  1. import { getBaseLang, isValidLang } from '../core/utils';
  2. function xmlLangMismatchMatches(node) {
  3. // using -> "selector": "html[lang][xml\\:lang]" to narrow down html with lang and xml:lang attributes
  4. // get primary base language for each of the attributes
  5. const primaryLangValue = getBaseLang(node.getAttribute('lang'));
  6. const primaryXmlLangValue = getBaseLang(node.getAttribute('xml:lang'));
  7. // ensure that the value specified is valid lang for both `lang` and `xml:lang`
  8. return isValidLang(primaryLangValue) && isValidLang(primaryXmlLangValue);
  9. }
  10. export default xmlLangMismatchMatches;