diff --git a/src/004-base/domPassage.js b/src/004-base/domPassage.js new file mode 100644 index 0000000000000000000000000000000000000000..441a8a87ef71ae7eaec796f7b57030bc4ce44811 --- /dev/null +++ b/src/004-base/domPassage.js @@ -0,0 +1,26 @@ +/** + * A pure DOM Passage, the SugarCube Wikifier never gets invoked. + */ +App.DomPassage = class extends Passage { + /** + * @param {string} title + * @param {function():DocumentFragment|function():HTMLElement} callback + * @param {string[]} tags + */ + constructor(title, callback, tags = []) { + super(title, { + hasAttribute: a => a === "tags", + getAttribute: () => tags.join(" ") + }); + this.callback = callback; + + Story.add(this); + } + + /** + * @returns {DocumentFragment|HTMLElement} + */ + render() { + return this.callback(); + } +};