Skip to content

Commit a4dc2af

Browse files
committed
update ojs runtime
1 parent 690b816 commit a4dc2af

File tree

2 files changed

+134
-28
lines changed

2 files changed

+134
-28
lines changed

src/resources/formats/html/ojs/quarto-ojs-runtime.js

Lines changed: 132 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -17802,6 +17802,138 @@ class OJSConnector {
1780217802
}
1780317803
}
1780417804

17805+
function createHtmlElement(tag, attrs, ...children) {
17806+
const el = document.createElement(tag); // we should try to play nice with svg etc a la d3
17807+
for (const [key, val] of Object.entries(attrs || {})) {
17808+
el.setAttribute(key, val);
17809+
}
17810+
while (children.length) {
17811+
const child = children.shift();
17812+
if (Array.isArray(child)) {
17813+
children.unshift(...child);
17814+
} else if (typeof child === "string") {
17815+
el.appendChild(document.createTextNode(child));
17816+
} else {
17817+
el.appendChild(child);
17818+
}
17819+
}
17820+
return el;
17821+
}
17822+
17823+
function createNamespacedElement(ns, tag, attrs, ...children) {
17824+
const el = document.createElementNS(ns, tag); // we should try to play nice with svg etc a la d3
17825+
for (const [key, val] of Object.entries(attrs || {})) {
17826+
el.setAttribute(key, val);
17827+
}
17828+
while (children.length) {
17829+
const child = children.shift();
17830+
if (Array.isArray(child)) {
17831+
children.unshift(...child);
17832+
} else if (typeof child === "string") {
17833+
el.appendChild(document.createTextNode(child));
17834+
} else {
17835+
el.appendChild(child);
17836+
}
17837+
}
17838+
return el;
17839+
}
17840+
17841+
const resolver = {
17842+
a: "svg",
17843+
animate: "svg",
17844+
animateMotion: "svg",
17845+
animateTransform: "svg",
17846+
circle: "svg",
17847+
clipPath: "svg",
17848+
defs: "svg",
17849+
desc: "svg",
17850+
discard: "svg",
17851+
ellipse: "svg",
17852+
feBlend: "svg",
17853+
feColorMatrix: "svg",
17854+
feComponentTransfer: "svg",
17855+
feComposite: "svg",
17856+
feConvolveMatrix: "svg",
17857+
feDiffuseLighting: "svg",
17858+
feDisplacementMap: "svg",
17859+
feDistantLight: "svg",
17860+
feDropShadow: "svg",
17861+
feFlood: "svg",
17862+
feFuncA: "svg",
17863+
feFuncB: "svg",
17864+
feFuncG: "svg",
17865+
feFuncR: "svg",
17866+
feGaussianBlur: "svg",
17867+
feImage: "svg",
17868+
feMerge: "svg",
17869+
feMergeNode: "svg",
17870+
feMorphology: "svg",
17871+
feOffset: "svg",
17872+
fePointLight: "svg",
17873+
feSpecularLighting: "svg",
17874+
feSpotLight: "svg",
17875+
feTile: "svg",
17876+
feTurbulence: "svg",
17877+
filter: "svg",
17878+
foreignObject: "svg",
17879+
g: "svg",
17880+
image: "svg",
17881+
line: "svg",
17882+
linearGradient: "svg",
17883+
marker: "svg",
17884+
mask: "svg",
17885+
metadata: "svg",
17886+
mpath: "svg",
17887+
path: "svg",
17888+
pattern: "svg",
17889+
polygon: "svg",
17890+
polyline: "svg",
17891+
radialGradient: "svg",
17892+
rect: "svg",
17893+
script: "svg",
17894+
set: "svg",
17895+
stop: "svg",
17896+
style: "svg",
17897+
svg: "svg",
17898+
switch: "svg",
17899+
symbol: "svg",
17900+
text: "svg",
17901+
textPath: "svg",
17902+
title: "svg",
17903+
tspan: "svg",
17904+
use: "svg",
17905+
view: "svg",
17906+
};
17907+
17908+
const nss = {
17909+
"svg": "http://www.w3.org/2000/svg"
17910+
};
17911+
17912+
function resolveCreator(tag) {
17913+
const nsKey = resolver[tag];
17914+
if (nsKey === undefined) {
17915+
return createHtmlElement;
17916+
}
17917+
const namespace = nss[nsKey];
17918+
17919+
return function(tag, attrs, ...children) {
17920+
return createNamespacedElement(namespace, tag, attrs, children);
17921+
}
17922+
}
17923+
17924+
function createQuartoJsxShim()
17925+
{
17926+
return {
17927+
createElement(tag, attrs, ...children) {
17928+
if (typeof tag === "function") {
17929+
return tag({...attrs, children });
17930+
}
17931+
17932+
return resolveCreator(tag)(tag, attrs, ...children);
17933+
}
17934+
};
17935+
}
17936+
1780517937
/*global Shiny, $, DOMParser, MutationObserver, URL
1780617938
*
1780717939
* quarto-ojs.js
@@ -18608,32 +18740,6 @@ function createRuntime() {
1860818740
return result;
1860918741
}
1861018742

18611-
function createQuartoJsxShim()
18612-
{
18613-
return {
18614-
createElement(tag, attrs, ...children) {
18615-
if (typeof tag === "function") {
18616-
return tag({...attrs, children });
18617-
}
18618-
18619-
const el = document.createElement(tag); // we should try to play nice with svg etc a la d3
18620-
for (const [key, val] of Object.entries(attrs || {})) {
18621-
el.setAttribute(key, val);
18622-
}
18623-
while (children.length) {
18624-
const child = children.shift();
18625-
if (Array.isArray(child)) {
18626-
children.unshift(...child);
18627-
} else if (typeof child === "string") {
18628-
el.appendChild(document.createTextNode(child));
18629-
} else {
18630-
el.appendChild(child);
18631-
}
18632-
}
18633-
return el;
18634-
}
18635-
};
18636-
}
1863718743

1863818744
function initializeRuntime()
1863918745
{

src/resources/formats/html/ojs/quarto-ojs-runtime.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)