Important Note About Use of This Example
From 536909749700d6bc96b6f32588eb790289b6eee9 Mon Sep 17 00:00:00 2001
From: Simon Pieters
Date: Thu, 28 May 2020 18:05:06 +0200
Subject: [PATCH 11/13] Make it work for pages with multiple examples and where
the 'Example' heading isn't the first h2
---
examples/js/app.js | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/examples/js/app.js b/examples/js/app.js
index 092a1f9ae6..f1c6b48796 100644
--- a/examples/js/app.js
+++ b/examples/js/app.js
@@ -7,7 +7,15 @@
function addSupportNotice() {
// The "Example" heading
- var exampleHeading = document.getElementById('ex_label');
+ var headings = document.querySelectorAll('h2');
+ var exampleHeading = null;
+ for (var i = 0; i < headings.length; ++i) {
+ var heading = headings[i];
+ if (heading.textContent.trim().match(/^Examples?$/)) {
+ exampleHeading = heading;
+ break;
+ }
+ }
if (!exampleHeading) {
return;
}
From 571092ed7bde71604bcdaa0b48fdfbe74e90d382 Mon Sep 17 00:00:00 2001
From: JaEun Jemma Ku
Date: Tue, 2 Jun 2020 12:40:17 -0500
Subject: [PATCH 12/13] moved notice msg before example heading
---
examples/js/app.js | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/examples/js/app.js b/examples/js/app.js
index f1c6b48796..9960946d1d 100644
--- a/examples/js/app.js
+++ b/examples/js/app.js
@@ -32,8 +32,9 @@
// Expected outcome '../js/app.js' OR '../../js/app.js'
var scriptSource = document.querySelector('[src$="app.js"]').getAttribute('src');
// Replace 'app.js' part with 'notice.html'
- var fetchSource = scriptSource.replace('app.js', 'notice.html');
+ var fetchSource = scriptSource.replace('app.js', './notice.html');
+ //fetch('https://raw.githack.com/w3c/aria-practices/1228-support-notice/examples/js/notice.html')
fetch(fetchSource)
.then(function(response) {
// Return notice.html as text
@@ -52,8 +53,8 @@
for (var i = 0; i < links.length; ++i) {
links[i].pathname = urlPrefix;
}
- // Insert the support notice after the page's example heading
- exampleHeading.parentNode.insertBefore(noticeElement, exampleHeading.nextSibling);
+ // Insert the support notice before the page's example heading
+ exampleHeading.parentNode.insertBefore(noticeElement, exampleHeading);
})
}
}());
From 057c5b3b05d974dc64884b56e3ea3b003a249d58 Mon Sep 17 00:00:00 2001
From: Valerie Young
Date: Fri, 26 Jun 2020 10:18:25 -0700
Subject: [PATCH 13/13] Move support notice under H1
---
examples/js/app.js | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/examples/js/app.js b/examples/js/app.js
index 9960946d1d..b74e006c6f 100644
--- a/examples/js/app.js
+++ b/examples/js/app.js
@@ -8,15 +8,14 @@
function addSupportNotice() {
// The "Example" heading
var headings = document.querySelectorAll('h2');
- var exampleHeading = null;
+ var foundExampleHeading;
for (var i = 0; i < headings.length; ++i) {
- var heading = headings[i];
- if (heading.textContent.trim().match(/^Examples?$/)) {
- exampleHeading = heading;
+ if (headings[i].textContent.trim().match(/^Examples?$/)) {
+ foundExampleHeading = true;
break;
}
}
- if (!exampleHeading) {
+ if (!foundExampleHeading) {
return;
}
@@ -53,8 +52,9 @@
for (var i = 0; i < links.length; ++i) {
links[i].pathname = urlPrefix;
}
- // Insert the support notice before the page's example heading
- exampleHeading.parentNode.insertBefore(noticeElement, exampleHeading);
+ // Insert the support notice before the page's h1
+ var heading = document.querySelector('h1');
+ heading.parentNode.insertBefore(noticeElement, heading.nextSibling);
})
}
}());