Second frontend, written in Next.JS + Typescript.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

0 lines
9.7 KiB

4 years ago
  1. {"ast":null,"code":"\"use strict\";\n\nexports.__esModule = true;\nexports[\"default\"] = initHeadManager;\nvar DOMAttributeNames = {\n acceptCharset: 'accept-charset',\n className: 'class',\n htmlFor: 'for',\n httpEquiv: 'http-equiv'\n};\n\nfunction reactElementToDOM(_ref) {\n var type = _ref.type,\n props = _ref.props;\n var el = document.createElement(type);\n\n for (var p in props) {\n if (!props.hasOwnProperty(p)) continue;\n if (p === 'children' || p === 'dangerouslySetInnerHTML') continue; // we don't render undefined props to the DOM\n\n if (props[p] === undefined) continue;\n var attr = DOMAttributeNames[p] || p.toLowerCase();\n el.setAttribute(attr, props[p]);\n }\n\n var children = props.children,\n dangerouslySetInnerHTML = props.dangerouslySetInnerHTML;\n\n if (dangerouslySetInnerHTML) {\n el.innerHTML = dangerouslySetInnerHTML.__html || '';\n } else if (children) {\n el.textContent = typeof children === 'string' ? children : children.join('');\n }\n\n return el;\n}\n\nfunction updateElements(type, components) {\n var headEl = document.getElementsByTagName('head')[0];\n var headCountEl = headEl.querySelector('meta[name=next-head-count]');\n\n if (true) {\n if (!headCountEl) {\n console.error('Warning: next-head-count is missing. https://err.sh/next.js/next-head-count-missing');\n return;\n }\n }\n\n var headCount = Number(headCountEl.content);\n var oldTags = [];\n\n for (var i = 0, j = headCountEl.previousElementSibling; i < headCount; i++, j = j.previousElementSibling) {\n if (j.tagName.toLowerCase() === type) {\n oldTags.push(j);\n }\n }\n\n var newTags = components.map(reactElementToDOM).filter(function (newTag) {\n for (var k = 0, len = oldTags.length; k < len; k++) {\n var oldTag = oldTags[k];\n\n if (oldTag.isEqualNode(newTag)) {\n oldTags.splice(k, 1);\n return false;\n }\n }\n\n return true;\n });\n oldTags.forEach(function (t) {\n return t.parentNode.removeChild(t);\n });\n newTags.forEach(function (t) {\n return headEl.insertBefore(t, headCountEl);\n });\n headCountEl.content = (headCount - oldTags.length + newTags.length).toString();\n}\n\nfunction initHeadManager() {\n var updatePromise = null;\n return function (head) {\n var promise = updatePromise = Promise.resolve().then(function () {\n if (promise !== updatePromise) return;\n updatePromise = null;\n var tags = {};\n head.forEach(function (h) {\n var components = tags[h.type] || [];\n components.push(h);\n tags[h.type] = components;\n });\n var titleComponent = tags.title ? tags.title[0] : null;\n var title = '';\n\n if (titleComponent) {\n var children = titleComponent.props.children;\n title = typeof children === 'string' ? children : children.join('');\n }\n\n if (title !== document.title) document.title = title;\n ['meta', 'base', 'link', 'style', 'script'].forEach(function (type) {\n updateElements(type, tags[type] || []);\n });\n });\n };\n}","map":{"version":3,"sources":["/data/projects/react/rpdata-frontend2/node_modules/next/dist/client/head-manager.js"],"names":["exports","__esModule","initHeadManager","DOMAttributeNames","acceptCharset","className","htmlFor","httpEquiv","reactElementToDOM","_ref","type","props","el","document","createElement","p","hasOwnProperty","undefined","attr","toLowerCase","setAttribute","children","dangerouslySetInnerHTML","innerHTML","__html","textContent","join","updateElements","components","headEl","getElementsByTagName","headCountEl","querySelector","console","error","headCount","Number","content","oldTags","i","j","previousElementSibling","tagName","push","newTags","map","filter","newTag","k","len","length","oldTag","isEqualNode","splice","forEach","t","parentNode","removeChild","insertBefore","toString","updatePromise","head","promise","Promise","resolve","then","tags","h","titleComponent","title"],"mappings":"AAAA;;AAAaA,OAAO,CAACC,UAAR,GAAmB,IAAnB;AAAwBD,OAAO,W