MCPcopy Create free account
hub / github.com/devflowinc/trieve / overlayAttributes

Function overlayAttributes

pdf2md/server/static/viewer.mjs:2946–2961  ·  view source on GitHub ↗
(fromElement, toElement)

Source from the content-addressed store, hash-verified

2944 return false;
2945}
2946function overlayAttributes(fromElement, toElement) {
2947 const explicitlyAllowed = toElement.hasAttribute("data-l10n-attrs") ? toElement.getAttribute("data-l10n-attrs").split(",").map(i => i.trim()) : null;
2948 for (const attr of Array.from(toElement.attributes)) {
2949 if (isAttrNameLocalizable(attr.name, toElement, explicitlyAllowed) && !hasAttribute(fromElement.attributes, attr.name)) {
2950 toElement.removeAttribute(attr.name);
2951 }
2952 }
2953 if (!fromElement.attributes) {
2954 return;
2955 }
2956 for (const attr of Array.from(fromElement.attributes)) {
2957 if (isAttrNameLocalizable(attr.name, toElement, explicitlyAllowed) && toElement.getAttribute(attr.name) !== attr.value) {
2958 toElement.setAttribute(attr.name, attr.value);
2959 }
2960 }
2961}
2962function getNodeForNamedElement(sourceElement, translatedChild) {
2963 const childName = translatedChild.getAttribute("data-l10n-name");
2964 const sourceChild = sourceElement.querySelector(`[data-l10n-name="${childName}"]`);

Callers 2

translateElementFunction · 0.85
shallowPopulateUsingFunction · 0.85

Calls 4

isAttrNameLocalizableFunction · 0.85
hasAttributeFunction · 0.85
trimMethod · 0.80
fromMethod · 0.45

Tested by

no test coverage detected