Ja som nutnosti Dúškom úlohy, ktoré pôjdu cez všetky priradené dokumenty HTML a odstrániť určité atribúty (ako napr. style=""). Myslel som, že som nebol schopný robiť to to isté, ako som to urobiť prostredníctvom prehliadača, ale vyzerá to nie. Tu je to, čo som sa snaží urobiť:
// function to take multiple attributes from an element
const discardAttributes = (element, ...attributes) =>
attributes.forEach((attribute) => element.removeAttribute(attribute));
// run the function on multiple elements
document.querySelectorAll("table, thead, tbody, tr, th, td").forEach((elem) => {
discardAttributes(elem, "cellspacing", "cellpadding", "width", "style");
});
Ja by som chcel potom sa vyššie uvedeného vzorca a vytvoriť dúškom.úlohou páči, takže:
const gulp = require("gulp");
gulp.task("clean", async () => {
gulp.src("src/*.html")
.pipe(discardAttributes())
.pipe(gulp.dest("dist"));
});
Ak nie je plug-v ktoré by som mohol využiť to, že bude robiť to, prosím, zdieľať, ale tiež, chcela by som sa dozvedieť, ako to urobiť ručne, ako je tento.
By som sa musieť použiť through2?
Ďakujem.