Skip to content

Commit a4f621b

Browse files
committed
mdn: mdn: handle scrim-inline elements
Make it look like external links, which should not be used for offline depls. Close #1071
1 parent 0f45f3a commit a4f621b

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

src/mdn/inject/inject.css

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,9 @@ div > section.place {
363363
margin: 0;
364364
}
365365

366+
/* https://github.com/website-local/mdn-local/issues/1071 */
366367
.curriculum-content-container.curriculum-module .curriculum-content scrim-inline[url],
367368
.curriculum-content-container.curriculum-overview .curriculum-content scrim-inline[url] {
368369
aspect-ratio: auto;
370+
margin: 0;
369371
}

src/mdn/inject/inject.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -964,4 +964,33 @@
964964
console.warn('toc-scroll-highlight', e);
965965
}
966966
/// endregion toc-scroll-highlight
967+
968+
/// region scrim-inline
969+
// mdn: handle scrim-inline elements #1071
970+
// https://github.com/website-local/mdn-local/issues/1071
971+
function scrimCustomElement() {
972+
// Create a class for the element
973+
class ScrimInline extends window.HTMLElement {
974+
constructor() {
975+
super();
976+
var a = document.createElement('a');
977+
a.href = this.getAttribute('url');
978+
a.innerText = this.getAttribute('scrimtitle');
979+
a.className = 'external';
980+
a.target = '_blank';
981+
this.appendChild(a);
982+
}
983+
}
984+
985+
// Define the new element
986+
window.customElements.define('scrim-inline', ScrimInline);
987+
988+
}
989+
990+
try {
991+
scrimCustomElement();
992+
} catch (e) {
993+
console.warn('scrim-inline', e);
994+
}
995+
/// endregion scrim-inline
967996
}();

0 commit comments

Comments
 (0)