MCPcopy
hub / github.com/ampproject/amphtml / getLanguageCodeFromElement

Function getLanguageCodeFromElement

third_party/subscriptions-project/swg.js:8688–8701  ·  view source on GitHub ↗

* Gets a language code (ex: "en-US") from a given Element. * @param {!Element} element * @return {string}

(element)

Source from the content-addressed store, hash-verified

8686 * @return {string}
8687 */
8688function getLanguageCodeFromElement(element) {
8689 if (element.lang) {
8690 // Get language from element itself.
8691 return element.lang;
8692 }
8693
8694 if (element.ownerDocument && element.ownerDocument.documentElement.lang) {
8695 // Get language from element's document.
8696 return element.ownerDocument.documentElement.lang;
8697 }
8698
8699 // There was an attempt.
8700 return DEFAULT_LANGUAGE_CODE;
8701}
8702
8703/**
8704 * Copyright 2018 The Subscribe with Google Authors. All Rights Reserved.

Callers 1

msgFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected