Browse Source

refactor(w3c/informative): remove jQuery (#1553)

* refactor(w3c/informative): remove jQuery

* add semicolon

* allow argument-less modern modules

* zero or one

* use queryselector again
pull/1558/head
Kagami Sascha Rosylight 5 years ago committed by GitHub
parent
commit
79b5d5405a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      src/core/base-runner.js
  2. 2
      src/core/best-practices.js
  3. 2
      src/w3c/abstract.js
  4. 7
      src/w3c/headers.js
  5. 13
      src/w3c/informative.js

4
src/core/base-runner.js

@ -27,8 +27,8 @@ function toRunnable(plug) {
performance.mark(name + "-start");
}
try {
// Modern plugins are async or normal functions, take one argument (conf)
if (plug.run.length === 1) {
// Modern plugins are async or normal functions, take zero or one argument (conf)
if (plug.run.length <= 1) {
await plug.run(config);
resolve();
} else {

2
src/core/best-practices.js

@ -8,7 +8,7 @@ import "deps/hyperhtml";
export const name = "core/best-practices";
export function run(conf) {
export function run() {
let num = 0;
const bps = document.querySelectorAll("span.practicelab");
const ul = document.createElement("ul");

2
src/w3c/abstract.js

@ -4,7 +4,7 @@ import { pub } from "core/pubsubhub";
import { l10n, lang } from "core/l10n";
export const name = "w3c/abstract";
export async function run(conf) {
export async function run() {
const abs = document.getElementById("abstract");
if (!abs) {
pub("error", `Document must have one element with \`id="abstract"`);

7
src/w3c/headers.js

@ -225,7 +225,7 @@ function validateDateAndRecover(conf, prop, fallbackDate = new Date()) {
return new Date(ISODate.format(new Date()));
}
export function run(conf, doc, cb) {
export function run(conf) {
conf.isUnofficial = conf.specStatus === "unofficial";
if (conf.isUnofficial) {
conf.logos = [];
@ -248,12 +248,12 @@ export function run(conf, doc, cb) {
if (conf.isRegular && !conf.shortName) {
pub("error", "Missing required configuration: `shortName`");
}
conf.title = doc.title || "No Title";
conf.title = document.title || "No Title";
if (!conf.subtitle) conf.subtitle = "";
conf.publishDate = validateDateAndRecover(
conf,
"publishDate",
doc.lastModified
document.lastModified
);
conf.publishYear = conf.publishDate.getUTCFullYear();
conf.publishHumanDate = W3CDate.format(conf.publishDate);
@ -601,7 +601,6 @@ export function run(conf, doc, cb) {
publishISODate: conf.publishISODate,
generatedSubtitle: `${conf.longStatus} ${conf.publishHumanDate}`,
});
cb();
}
function populateSoTD(conf, sotd) {

13
src/w3c/informative.js

@ -1,10 +1,13 @@
// Module w3c/informative
// Mark specific sections as informative, based on CSS
import "deps/hyperhtml";
export const name = "w3c/informative";
export function run(conf, doc, cb) {
$("section.informative")
.find("> h2:first, > h3:first, > h4:first, > h5:first, > h6:first")
.after("<p><em>This section is non-normative.</em></p>");
cb();
export function run() {
Array.from(document.querySelectorAll("section.informative"))
.map(informative => informative.querySelector("h2, h3, h4, h5, h6"))
.filter(heading => heading)
.forEach(heading => {
heading.parentNode.insertBefore(hyperHTML`<p><em>This section is non-normative.</em></p>`, heading.nextSibling);
});
}

Loading…
Cancel
Save