(p5, fn)
| 20 | import { File } from './p5.File'; |
| 21 | |
| 22 | function dom(p5, fn){ |
| 23 | /** |
| 24 | * Searches the page for the first element that matches the given |
| 25 | * <a href="https://developer.mozilla.org/en-US/docs/Learn/Getting_started_with_the_web/CSS_basics#different_types_of_selectors" target="_blank">CSS selector string</a>. |
| 26 | * |
| 27 | * The selector string can be an ID, class, tag name, or a combination. |
| 28 | * `select()` returns a <a href="#/p5.Element">p5.Element</a> object if it |
| 29 | * finds a match and `null` if not. |
| 30 | * |
| 31 | * The second parameter, `container`, is optional. It specifies a container to |
| 32 | * search within. `container` can be CSS selector string, a |
| 33 | * <a href="#/p5.Element">p5.Element</a> object, or an |
| 34 | * <a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement" target="_blank">HTMLElement</a> object. |
| 35 | * |
| 36 | * @method select |
| 37 | * @param {String} selectors CSS selector string of element to search for. |
| 38 | * @param {String|p5.Element|HTMLElement} [container] CSS selector string, <a href="#/p5.Element">p5.Element</a>, or |
| 39 | * <a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement" target="_blank">HTMLElement</a> to search within. |
| 40 | * @return {p5.Element|null} <a href="#/p5.Element">p5.Element</a> containing the element. |
| 41 | * |
| 42 | * @example |
| 43 | * function setup() { |
| 44 | * createCanvas(100, 100); |
| 45 | * background(200); |
| 46 | * |
| 47 | * // Select the canvas by its tag. |
| 48 | * let cnv = select('canvas'); |
| 49 | * cnv.style('border', '5px deeppink dashed'); |
| 50 | * |
| 51 | * describe('A gray square with a dashed pink border.'); |
| 52 | * } |
| 53 | * |
| 54 | * @example |
| 55 | * function setup() { |
| 56 | * let cnv = createCanvas(100, 100); |
| 57 | * |
| 58 | * // Add a class attribute to the canvas. |
| 59 | * cnv.class('pinkborder'); |
| 60 | * |
| 61 | * background(200); |
| 62 | * |
| 63 | * // Select the canvas by its class. |
| 64 | * cnv = select('.pinkborder'); |
| 65 | * |
| 66 | * // Style its border. |
| 67 | * cnv.style('border', '5px deeppink dashed'); |
| 68 | * |
| 69 | * describe('A gray square with a dashed pink border.'); |
| 70 | * } |
| 71 | * |
| 72 | * @example |
| 73 | * function setup() { |
| 74 | * let cnv = createCanvas(100, 100); |
| 75 | * |
| 76 | * // Set the canvas' ID. |
| 77 | * cnv.id('mycanvas'); |
| 78 | * |
| 79 | * background(200); |
no test coverage detected