Skip to content

Commit

Permalink
docs: document symbol
Browse files Browse the repository at this point in the history
  • Loading branch information
sntran authored Apr 29, 2024
1 parent eac0148 commit 098574b
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,25 @@ import {
HTMLRewriter as BaseHTMLRewriter,
} from "npm:[email protected]";

/**
* An API for traversing and transforming HTML documents.
*
* Example:
*
* ```ts
* import { HTMLRewriter } from "./mod.ts";
*
* const rewriter = new HTMLRewriter();
* rewriter.on("img, iframe", {
* element(element) {
* if (!element.hasAttribute("loading")) {
* element.setAttribute("loading", "lazy");
* }
* },
* });
* rewriter.transform(await fetch("https://example.com"));
* ```
*/
export class HTMLRewriter {
#elementHandlers: Array<[string, ElementHandlers]> = [];
#documentHandlers: Array<DocumentHandlers> = [];
Expand Down

0 comments on commit 098574b

Please sign in to comment.