Merge pull request #6053 from overleaf/ta-pdf-detach-tests

PDF Detach Misc Tests

GitOrigin-RevId: 9615c8fdfd8964a9c63d7c91e4596d397a1d35dc
This commit is contained in:
Timothée Alby
2021-12-15 09:04:46 +00:00
committed by Copybot
parent 1201a733d9
commit 44eca312ff
16 changed files with 817 additions and 28 deletions
+5 -3
View File
@@ -1,10 +1,12 @@
import _ from 'lodash'
// cache for parsed values
const cache = new Map()
window.metaAttributesCache = window.metaAttributesCache || new Map()
export default function getMeta(name, fallback) {
if (cache.has(name)) return cache.get(name)
if (window.metaAttributesCache.has(name)) {
return window.metaAttributesCache.get(name)
}
const element = document.head.querySelector(`meta[name="${name}"]`)
if (!element) {
return fallback
@@ -28,7 +30,7 @@ export default function getMeta(name, fallback) {
default:
value = plainTextValue
}
cache.set(name, value)
window.metaAttributesCache.set(name, value)
return value
}