This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 15 February 2024 | |
// many ways to access forms and elements in the DOM | |
var input = document.createElement("input"); | |
input.name = "E"; | |
var form = document.createElement("form"); | |
form.name = "F"; | |
form.appendChild(input); | |
document.body.appendChild(form); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 12 December 2023 | |
// Shadow DOM mutation benchmark | |
// How long does it take to update the Shadow DOM? | |
// Successor to "How long does it take to update the DOM?" gist at | |
// https://gist.github.com/dfkaye/6ceef75ee61892428ef09b3b67138cd5 | |
// In this test, as before, we create a table with a tbody, 1000 rows (<tr>), | |
// where each row contains 4 cells (<td>), and perform updates on all 4000 cells |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 11 December 2023 | |
// DOM mutation benchmark | |
// How long does it take to update the DOM? | |
// Continued by "How long does it take to update the Shadow DOM?" gist at | |
// https://gist.github.com/dfkaye/1c4068e05b5d891a394d8c97fbe87684 | |
// When it comes to those fastest DOM mutation framework benchmarks, ask how |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 21 November 2023 | |
// convergence test for pseudo-stochastic monte carloesque dynamically updated | |
// loop exit condition | |
// program proof that loops with changing random length converge on square root | |
// of max length (from a Tweet the other day that jonathan blow responded to). | |
// T asked why programmers think a loop with length reset to random * 100 will | |
// average to 50 instead of 10 (well, actually, it will converge on the square | |
// root of max plus 2, given the first two steps always execute). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 29 September 2023 | |
// What's in an array? | |
// Here's an array: | |
var a = [1,2,3,4]; | |
// If we use want only the *own* properties of an array, we can use the | |
// Object.keys() method to inspect it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 21 September 2023 | |
// Collect a node's Comment, Text, and Attribute child nodes | |
// should break this up into separate functions focused on node type | |
// then find items by their nodeValue | |
function collect(node) { | |
var comments = []; | |
var text = []; | |
var attributes = []; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 27 September 2023 | |
// onpropertychange signal v.9 | |
// cf. v.8 https://gist.github.com/dfkaye/548622151971122110bf4047ae3ac432 | |
// and v.1 https://gist.github.com/dfkaye/619c5f31080fce2cd383ac966e132311 | |
// Success, at last! v.9 supports both Object and EventTarget. | |
// Investigating where proxy on an array allows array.push mutations, the goal | |
// here was to get the proxy to work on EventTarget and Object, this time with |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 26 September 2023 | |
// onpropertychange signal v.8 | |
// cont'd from https://gist.github.com/dfkaye/3affad4c43e363a84ac4320eae375129 | |
// Going back to v.1 prototype enhancement/pollution, (see | |
// https://gist.github.com/dfkaye/619c5f31080fce2cd383ac966e132311), trying to | |
// simplify the prototype stack. | |
// The signals and delegate properties are assigned on the target using the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 22 September 2023 | |
// onpropertychange signal v.7 | |
// cont'd from https://gist.github.com/dfkaye/1d9a55b8fe6659df7ba7c04edbd24bf7 | |
// Another one that seems to work (we get events from Array changes) but my | |
// reasoning in the comments seems hand-wavingly suspect. | |
// Method delegation adds more setup time (iterating and so on), another mapping | |
// dependency, and copying the prototype and setting that as the new prototype |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 21 September 2023 | |
// onpropertychange signal v.6 already | |
// cont'd from https://gist.github.com/dfkaye/dae6958adf813735d9154be23a0ebb09 | |
// Still not happy but we have better support across types of objects (only | |
// element, text, object, and array so far). | |
// After all that, Object.defineProperty on property names is enough to ensure | |
// related property updates, e.g., {textContent, nodeValue, data, wholeText}. |