diff --git a/src/current.ts b/src/current.ts index 900572f..c13cd1c 100644 --- a/src/current.ts +++ b/src/current.ts @@ -9,20 +9,19 @@ const currentProxy = { const prefix = config.prefix ? `${config.prefix}-` : "" const metaName = `${prefix}${propertyName}` - const exact = document.head.querySelector(`meta[name=${metaName}]`) - const startsWith = Array.from(document.head.querySelectorAll(`meta[name^=${metaName}-]`)) + const startsWith = document.head.querySelectorAll(`meta[name^=${metaName}-]`) if (startsWith.length > 0) { - for (const { name, content } of startsWith) { + startsWith.forEach(({ name, content }) => { const key = camelize(name.slice(metaName.length + 1)) - if (result[key]) continue + if (result[key]) return result[key] = content - } - } else if (exact) { - return exact.content + }) + return result } - return result + const exact = document.head.querySelector(`meta[name=${metaName}]`) + return exact ? exact.content : result }, }