This file contains 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
// 3 March 2024 | |
// generate an XPath expression for an element in an HTML document | |
// ONLY WORKS FOR ELEMENTS SO FAR, NO FANCY NODE TYPE SELECTION YET | |
// for an element tree structure such as | |
// <a><b><c><d id="test"> this is <e> embedded </e> text </d></c></b></a> | |
// the XPath expression for window.test (id="test") should be | |
// //BODY[1]/A[1]/B[1]/C[1]/D[1] | |
// and passing that to document.evaluate() should return |
This file contains 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
// 2 March 2024 | |
// import XML source documents into XSLT using the document() function. | |
// example markup borrowed from | |
// https://www.abbeyworkshop.com/howto/xslt/document/ | |
// parsing function defined in gist 19 June 2023, | |
// "Using XML, XSLT, XHR, to parse and serialize HTML in the browser", | |
// https://gist.github.com/dfkaye/94bc03241c4c3bf458ab0dc5d56b1958 | |
// 17 May 2024 |
This file contains 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 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 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 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 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 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 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 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 |