Skip to content

Commit d21108c

Browse files
authored
fix: update maidr attribute to maidr-data for py-maidr to handle (#636)
1 parent cd644e0 commit d21108c

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

galleries/attributes/bar_plot.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
version="1.1"
2222
id="barplot1"
2323
tabindex="0"
24-
maidr="{"type":"bar","id":"barplot1","title":"The Number of Diamonds by Cut.","selector":"g[id^=\"geom_rect\"] > rect","axes":{"x":{"label":"Cut","level":["Fair","Good","Very Good","Premium","Ideal"]},"y":{"label":"Count"}},"data":[1610,4906,12082,13791,21551]}"
25-
>
24+
maidr-data='{"type":"bar","id":"barplot1","title":"The Number of Diamonds by Cut.","selector":"g[id^=\"geom_rect\"] > rect","axes":{"x":{"label":"Cut","level":["Fair","Good","Very Good","Premium","Ideal"]},"y":{"label":"Count"}},"data":[1610,4906,12082,13791,21551]}'
25+
>
2626
<metadata
2727
xmlns:gridsvg="http://www.stat.auckland.ac.nz/~paul/R/gridSVG/"
2828
>

src/js/init.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ document.addEventListener('DOMContentLoaded', function (e) {
1010

1111
// set focus events for all charts matching maidr ids
1212
let maidrObjects = [];
13-
13+
1414
// First check for globally defined maidr variable (script tag method)
1515
if (typeof window.maidr !== 'undefined') {
1616
if (!Array.isArray(window.maidr)) {
@@ -21,10 +21,10 @@ document.addEventListener('DOMContentLoaded', function (e) {
2121
}
2222

2323
// Then look for elements with maidr attribute
24-
const elementsWithMaidrAttr = document.querySelectorAll('[maidr]');
25-
elementsWithMaidrAttr.forEach(element => {
24+
const elementsWithMaidrAttr = document.querySelectorAll('[maidr-data]');
25+
elementsWithMaidrAttr.forEach((element) => {
2626
try {
27-
const maidrData = JSON.parse(element.getAttribute('maidr'));
27+
const maidrData = JSON.parse(element.getAttribute('maidr-data'));
2828
// If id is not provided in the JSON, use the element's id
2929
if (!maidrData.id) {
3030
if (element.id) {
@@ -36,7 +36,7 @@ document.addEventListener('DOMContentLoaded', function (e) {
3636
}
3737
}
3838
// Check if this id already exists in maidrObjects to avoid duplicates
39-
if (!maidrObjects.some(obj => obj.id === maidrData.id)) {
39+
if (!maidrObjects.some((obj) => obj.id === maidrData.id)) {
4040
maidrObjects.push(maidrData);
4141
}
4242
} catch (e) {

0 commit comments

Comments
 (0)