{"_id":"mutation-events","_rev":"7-ea7b6c8da9a6a2f685abd973f825fa3a","name":"mutation-events","dist-tags":{"latest":"1.0.8"},"versions":{"1.0.1":{"name":"mutation-events","version":"1.0.1","keywords":["Mutation Events","Mutation Observer"],"author":{"name":"Mason Freed","email":"mfreed@mfreed.com"},"license":"BSD-3-Clause","_id":"mutation-events@1.0.1","maintainers":[{"name":"mfreed7","email":"mfreed@mfreed.com"}],"homepage":"https://github.com/mfreed7/mutation-events-polyfill#readme","bugs":{"url":"https://github.com/mfreed7/mutation-events-polyfill/issues"},"dist":{"shasum":"5091911c0eaf678b7a00b01a1f1ec724a2bdb8c9","tarball":"https://registry.npmjs.org/mutation-events/-/mutation-events-1.0.1.tgz","fileCount":5,"integrity":"sha512-96/CH2cqWXBwoEU7SVneTrMoI+LEvWPA8/1eEGslYuV7P9N6Fk2LRRUmrMqtQ1loRYY7mxIEtq4d8P5MvLygqA==","signatures":[{"sig":"MEUCIF9Rxw46ac0VegtleDE8vjxNie0P3q+vROcgLV4SuimGAiEAtvwvuB6/8JYyoMHUCGlwJkrjXL3NpeSM+lyhXMMeke0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":25504},"gitHead":"614bc06ce0acb19f179cdd10ae88d7687368c17a","_npmUser":{"name":"mfreed7","email":"mfreed@mfreed.com"},"_npmVersion":"8.19.2","description":"A polyfill for Mutation Events, using Mutation Observer","directories":{},"_nodeVersion":"18.11.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/mutation-events_1.0.1_1684787281674_0.42648505765098776","host":"s3://npm-registry-packages"}},"1.0.2":{"name":"mutation-events","version":"1.0.2","keywords":["Mutation Events","Mutation Observer"],"author":{"name":"Mason Freed","email":"mfreed@mfreed.com"},"license":"BSD-3-Clause","_id":"mutation-events@1.0.2","maintainers":[{"name":"mfreed7","email":"mfreed@mfreed.com"}],"homepage":"https://github.com/mfreed7/mutation-events-polyfill#readme","bugs":{"url":"https://github.com/mfreed7/mutation-events-polyfill/issues"},"dist":{"shasum":"79ce6af99d06d1074fb207499329bc57f64f696b","tarball":"https://registry.npmjs.org/mutation-events/-/mutation-events-1.0.2.tgz","fileCount":5,"integrity":"sha512-fYzZF36yzDImtCZ6EW6zeWWuy2Etggby1rt4zkeOXqm47MrX5een9CcGSXlnR1vWL5gfJzvwkw9eyYOXFyi02g==","signatures":[{"sig":"MEUCICcqVEJPjeAzO8ELDNb5HtyzP8UG3oOjofhN1dtdECEeAiEAhOTmvGuX7SK39zlvrQtVFKa3KElXkdOLXlEX7gQn58U=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":25504},"gitHead":"a6c5cc4be8b94b51aed2d0ff404bde65a1cd4570","_npmUser":{"name":"mfreed7","email":"mfreed@mfreed.com"},"_npmVersion":"8.19.2","description":"A polyfill for Mutation Events, using Mutation Observer","directories":{},"_nodeVersion":"18.11.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/mutation-events_1.0.2_1684787401398_0.27843573341091665","host":"s3://npm-registry-packages"}},"1.0.3":{"name":"mutation-events","version":"1.0.3","keywords":["Mutation Events","Mutation Observer"],"author":{"name":"Mason Freed","email":"mfreed@mfreed.com"},"license":"BSD-3-Clause","_id":"mutation-events@1.0.3","maintainers":[{"name":"mfreed7","email":"mfreed@mfreed.com"}],"homepage":"https://github.com/mfreed7/mutation-events-polyfill#readme","bugs":{"url":"https://github.com/mfreed7/mutation-events-polyfill/issues"},"dist":{"shasum":"5c7a6fe31e73804023fee4d3481b5a185ff9a06a","tarball":"https://registry.npmjs.org/mutation-events/-/mutation-events-1.0.3.tgz","fileCount":5,"integrity":"sha512-O37AraZdC87TWlicdue7OJrWVM+Md/GwTI6eHOLDoJ5iz/pPNq9egUsjn935A7ywhQhl9p6Vs6pOI9m3M12VHQ==","signatures":[{"sig":"MEUCIGnmr3SLJGJL+5o6yki8zxh7fa7ce1y9LzcZggZ+O7edAiEAzbY1S9RBQ1GzM0+o/F05mN/iF9kk3NEemER1ZxWmQ7o=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":25669},"main":"src/mutation_events.js","gitHead":"c3cab34745141e53e632e4efeab24b1d8bf88b86","_npmUser":{"name":"mfreed7","email":"mfreed@mfreed.com"},"repository":{"url":"git://github.com/mfreed7/mutation-events-polyfill.git","type":"git"},"_npmVersion":"8.19.2","description":"A polyfill for Mutation Events, using Mutation Observer","directories":{},"_nodeVersion":"18.11.0","dependencies":{},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/mutation-events_1.0.3_1684855466120_0.6483407407311894","host":"s3://npm-registry-packages"}},"1.0.4":{"name":"mutation-events","version":"1.0.4","keywords":["Mutation Events","Mutation Observer"],"author":{"name":"Mason Freed","email":"mfreed@mfreed.com"},"license":"BSD-3-Clause","_id":"mutation-events@1.0.4","maintainers":[{"name":"mfreed7","email":"mfreed@mfreed.com"}],"homepage":"https://github.com/mfreed7/mutation-events-polyfill#readme","bugs":{"url":"https://github.com/mfreed7/mutation-events-polyfill/issues"},"dist":{"shasum":"0b0ebe011cebd5e93e2c455af7b325eecf2063f6","tarball":"https://registry.npmjs.org/mutation-events/-/mutation-events-1.0.4.tgz","fileCount":6,"integrity":"sha512-ZTQ8hHn5CI5x5RO2IlJ6KKzGcjW3MwgKgNrhnHYmCL1b1eQ+CXOcMym8jm/3aatpEWT0oEAiR6b04hqI3wSCqw==","signatures":[{"sig":"MEQCIDC90u2VPv+FwrGpn3R9XMt6/UGfvWbKVR9VpyH4st+7AiBfrEancP1u7awQBWGn8Mgn6LC0rjIp2HPP7lQDXXIlgw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":28922},"main":"src/mutation_events.js","gitHead":"d4cbcc93c4cbe513018a5b912c93873442a45143","_npmUser":{"name":"mfreed7","email":"mfreed@mfreed.com"},"repository":{"url":"git://github.com/mfreed7/mutation-events-polyfill.git","type":"git"},"_npmVersion":"8.19.2","description":"A polyfill for Mutation Events, using Mutation Observer","directories":{},"_nodeVersion":"18.11.0","dependencies":{},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/mutation-events_1.0.4_1685054131715_0.5013351312828345","host":"s3://npm-registry-packages"}},"1.0.5":{"name":"mutation-events","version":"1.0.5","keywords":["Mutation Events","Mutation Observer"],"author":{"name":"Mason Freed","email":"mfreed@mfreed.com"},"license":"BSD-3-Clause","_id":"mutation-events@1.0.5","maintainers":[{"name":"mfreed7","email":"mfreed@mfreed.com"}],"homepage":"https://github.com/mfreed7/mutation-events-polyfill#readme","bugs":{"url":"https://github.com/mfreed7/mutation-events-polyfill/issues"},"dist":{"shasum":"58ecafea89b0a4a433b49b52bf67c241fd6e0137","tarball":"https://registry.npmjs.org/mutation-events/-/mutation-events-1.0.5.tgz","fileCount":6,"integrity":"sha512-bH+KAuFc164jwckJohvq7YObHdCn5aZWca6y2EWwWxhuEkSZ3jCViq7KrhqMq2eSx946arl/YLHwaGzQJm3eUQ==","signatures":[{"sig":"MEQCIAUiXwMzAa5tsiT532Qf917fD7UZLPZPxCOI1+9ilwvOAiBQQGYsKEyR40d9T6lzj6IQG7IM5iklDDEjAAiMc8PcBw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":30512},"main":"src/mutation_events.js","gitHead":"e235ba5bc0473e580de0d8842b6351f09893c028","_npmUser":{"name":"mfreed7","email":"mfreed@mfreed.com"},"repository":{"url":"git://github.com/mfreed7/mutation-events-polyfill.git","type":"git"},"_npmVersion":"10.2.4","description":"A polyfill for Mutation Events, using Mutation Observer","directories":{},"_nodeVersion":"21.5.0","dependencies":{},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/mutation-events_1.0.5_1706833754621_0.650351255210567","host":"s3://npm-registry-packages"}},"1.0.6":{"name":"mutation-events","version":"1.0.6","keywords":["Mutation Events","Mutation Observer"],"author":{"name":"Mason Freed","email":"mfreed@mfreed.com"},"license":"BSD-3-Clause","_id":"mutation-events@1.0.6","maintainers":[{"name":"mfreed7","email":"mfreed@mfreed.com"}],"homepage":"https://github.com/mfreed7/mutation-events-polyfill#readme","bugs":{"url":"https://github.com/mfreed7/mutation-events-polyfill/issues"},"dist":{"shasum":"cc294de74a08b4b2b788a3377e4ab1c641af4034","tarball":"https://registry.npmjs.org/mutation-events/-/mutation-events-1.0.6.tgz","fileCount":7,"integrity":"sha512-G7SSxGSdmyTp5aSDX7NsKwqHpX8LnPuB+zmbkIHeKp0SbN7muN9iUMaYjPHodci9DKy15lxTsgry/OI/bRCC5A==","signatures":[{"sig":"MEUCIQC3+xAvu+uM+/KdhQIrmdxb2WjpSpkEgfLtGA/XbaNMmwIgW6HXccftTjmKYa23ePuv8dIQ5eSnU0HRmnubFRW+IRE=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":37661},"main":"src/mutation_events.min.js","gitHead":"5d59b6ace1f29f8fb1595a67c535bcbe0a71c109","_npmUser":{"name":"mfreed7","email":"mfreed@mfreed.com"},"repository":{"url":"git://github.com/mfreed7/mutation-events-polyfill.git","type":"git"},"_npmVersion":"10.2.4","description":"A polyfill for Mutation Events, using Mutation Observer","directories":{},"_nodeVersion":"21.5.0","dependencies":{},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/mutation-events_1.0.6_1722352844019_0.5464395275454503","host":"s3://npm-registry-packages"}},"1.0.7":{"name":"mutation-events","version":"1.0.7","keywords":["Mutation Events","Mutation Observer"],"author":{"name":"Mason Freed","email":"mfreed@mfreed.com"},"license":"BSD-3-Clause","_id":"mutation-events@1.0.7","maintainers":[{"name":"mfreed7","email":"mfreed@mfreed.com"}],"homepage":"https://github.com/mfreed7/mutation-events-polyfill#readme","bugs":{"url":"https://github.com/mfreed7/mutation-events-polyfill/issues"},"dist":{"shasum":"6ab8ff3614fb44c6b196b23d5f34741223b50fb8","tarball":"https://registry.npmjs.org/mutation-events/-/mutation-events-1.0.7.tgz","fileCount":7,"integrity":"sha512-zptHqaAgtvmjg7dmO92NKZhX7B8QAuL9AY1zis/Hda4qVIg7YzBle0oyV4t1J/RC9x8wFVg0Pd5eA1ABQJYoCA==","signatures":[{"sig":"MEUCIDkHVMdQ4viWXZ1Tj+bL2FaBWoHrBi80JEwvAdt/IEHUAiEAtSBGyxbx7NvT7YwlShARobT9H9ws76KGCogcbXLOf30=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":37705},"main":"src/mutation_events.min.js","gitHead":"70d496a885e600a810957276a0428b5ac84b9cbd","_npmUser":{"name":"mfreed7","email":"mfreed@mfreed.com"},"repository":{"url":"git://github.com/mfreed7/mutation-events-polyfill.git","type":"git"},"_npmVersion":"10.2.4","description":"A polyfill for Mutation Events, using Mutation Observer","directories":{},"_nodeVersion":"21.5.0","dependencies":{},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/mutation-events_1.0.7_1723051648729_0.08834835721901113","host":"s3://npm-registry-packages"}},"1.0.8":{"name":"mutation-events","version":"1.0.8","description":"A polyfill for Mutation Events, using Mutation Observer","keywords":["Mutation Events","Mutation Observer"],"homepage":"https://github.com/mfreed7/mutation-events-polyfill#readme","bugs":{"url":"https://github.com/mfreed7/mutation-events-polyfill/issues"},"repository":{"type":"git","url":"git://github.com/mfreed7/mutation-events-polyfill.git"},"author":{"name":"Mason Freed","email":"mfreed@mfreed.com"},"license":"BSD-3-Clause","main":"src/mutation_events.min.js","dependencies":{},"_id":"mutation-events@1.0.8","gitHead":"459351a28ef776a0f1bc29d164fd5a24b7f3d06c","_nodeVersion":"21.5.0","_npmVersion":"10.2.4","dist":{"integrity":"sha512-gWRhqbHsUSsGRTI2WGJtelsTiCyOTgWaacLie2tT9UQo3xgcSSyO1G+KEOJGX3GwNcYGRNsVF+FS+QgidApacg==","shasum":"c4f08bab5923aa3e0720a6d4c1b361d09ca53a4e","tarball":"https://registry.npmjs.org/mutation-events/-/mutation-events-1.0.8.tgz","fileCount":7,"unpackedSize":38260,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCsoDS/+6PuPcRlj/77ZBXayKieqOmU13DnN6Mc9cm2QQIhAJtTWjkyvF9ZQpxj89VMPmUxIlS4xG9paxYEWekb/0up"}]},"_npmUser":{"name":"mfreed7","email":"mfreed@mfreed.com"},"directories":{},"maintainers":[{"name":"mfreed7","email":"mfreed@mfreed.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mutation-events_1.0.8_1724438708589_0.012654177672730693"},"_hasShrinkwrap":false}},"time":{"created":"2023-05-22T20:28:01.674Z","modified":"2024-08-23T18:45:08.937Z","1.0.1":"2023-05-22T20:28:01.828Z","1.0.2":"2023-05-22T20:30:01.678Z","1.0.3":"2023-05-23T15:24:26.292Z","1.0.4":"2023-05-25T22:35:31.885Z","1.0.5":"2024-02-02T00:29:14.869Z","1.0.6":"2024-07-30T15:20:44.262Z","1.0.7":"2024-08-07T17:27:29.018Z","1.0.8":"2024-08-23T18:45:08.788Z"},"bugs":{"url":"https://github.com/mfreed7/mutation-events-polyfill/issues"},"author":{"name":"Mason Freed","email":"mfreed@mfreed.com"},"license":"BSD-3-Clause","homepage":"https://github.com/mfreed7/mutation-events-polyfill#readme","keywords":["Mutation Events","Mutation Observer"],"repository":{"type":"git","url":"git://github.com/mfreed7/mutation-events-polyfill.git"},"description":"A polyfill for Mutation Events, using Mutation Observer","maintainers":[{"name":"mfreed7","email":"mfreed@mfreed.com"}],"readme":"# mutation-events Polyfill\n\nThis is a polyfill of the Mutation Events:\n  - DOMCharacterDataModified\n  - DOMNodeInserted\n  - DOMNodeInsertedIntoDocument\n  - DOMNodeRemoved\n  - DOMNodeRemovedFromDocument\n  - DOMSubtreeModified\n\n## Usage\nTo use this polyfill, simply load it before any calls to `addEventListener`\nfor Mutation Events:\n\n  ```html\n  <script src=\"mutation_events.min.js\"></script>\n  <div id=target></div>\n  <script>\n  target.addEventListener('DOMNodeInserted',() => {});\n  </script>\n  ```\n\n## Implementation / Behavior\nThe polyfill monkeypatches `addEventListener` and `removeEventListener`\nand attaches a Mutation Observer whenever addEventListener is called with\na Mutation Event name. Mutation Observer is well supported by all evergreen\nbrowsers. The polyfill also adds an implementation of the `MutationEvent`\nclass, and monkeypatches Document.createEvent so that it can be created.\n\nThere is no standard for Mutation Events, and indeed there are some\ndifferences between rendering engines. Roughly, for a listener on `target`,\nthe behavior is:\n\n<dl>\n<dt><code>DOMNodeInserted</code></dt>\n<dd>fired whenever a node is inserted into a new parent. This\nevent bubbles up through the *NEW* parent.</dd>\n<dt><code>DOMNodeRemoved</code></dt>\n<dd>fired whenever a node is removed from a parent. This event\nbubbles up through the *OLD* parent.</dd>\n<dt><code>DOMSubtreeModified</code></dt>\n<dd>fired whenever any node in the SUBTREE of `target` is\nmodified, including: a) node inserted, b) node removed,\nc) attributes added, d) attributes removed, or e) character\ndata modified. This event is also fired when attributes are\nadded or removed from `target`. It is not fired when\nexisting attributes are changed.</dd>\n<dt><code>DOMNodeInsertedIntoDocument</code></dt>\n<dd>fired whenever a node is inserted. This event\ndoes not bubble, but is fired on every sub-node\nin the inserted tree, plus the (new) parent of\nthe inserted tree.</dd>\n<dt><code>DOMNodeRemovedFromDocument</code></dt>\n<dd>fired whenever a node is removed. This event\ndoes not bubble, but is fired on every sub-node\nin the removed tree, plus the (old) parent of\nthe removed tree.</dd>\n<dt><code>DOMCharacterDataModified</code></dt>\n<dd>fired whenever a text/comment node has its data\nmodified.</dd>\n</dl>\n\nThis polyfill is based on the behavior of Chrome v115, which differs from\nSafari and Firefox in a few ways:\n  1. Firefox does not fire `DOMNodeInsertedIntoDocument` or\n     `DOMNodeRemovedFromDocument`. Chrome and Safari do. This polyfill does.\n  2. Firefox fires `DOMSubtreeModified` events when attributes are modified\n     via `target.setAttribute()`, but not when changed directly via\n     `target.attributes[0].value=foo`. Chrome and Safari do not fire events\n     in either of those cases, and neither does this polyfill.\n  3. Chrome and Safari fire two sets of `DOMSubtreeModified` events when\n     nodes are both added and removed, e.g. via a call to `replaceChildren()`.\n     They differ on the timing of the second set. Firefox only fires a\n     single set of `DOMSubtreeModified` events. This polyfill fires two sets\n     of `DOMSubtreeModified` events.\n  4. Generally, Firefox fires bubble listeners before capture listeners\n     on the target node, which seems broken anyway. This polyfill fires\n     capture before bubble.\n\n\n## Behavior differences\n\nThere is one major differences between native Mutation Events and this polyfill\nwhich uses Mutation Observer. Since Mutation Events are synchronous, they are\nfired *during* the mutation. In contrast, Mutation Observers are fired at\nmicrotask timing, which is *after* the mutation. One place where this leads to\nobservable differences is during the `DOMNodeRemoved` event. Native\n`DOMNodeRemoved` events are fired before the node is removed from\nits parent, while this polyfill fires those after the removal is complete.\nThat leads to the event needing to be fired two places - on the removed\nnode and *also* on the observed target, because ordinarily the event bubbles\nfrom the former to the latter.\n\nAdditionally, the order of events is not always the same between native\nMutation Events and the events dispatched by this polyfill. But they're\nclose.\n\nFinally, the `relatedNode` field of the dispatched events is often `null` when\nusing the polyfill. Ordinarily, `relatedNode` points to e.g. the old parent\nelement for `DOMNodeRemoved`, or the new parent element for `DOMNodeInserted`.\nWhile the polyfill attempts to set this field correctly, it misses in several\ncases. The tests do not currently check `relatedNode` for correctness.\n\n## Tests\n\nThe `test/test.html` file performs several DOM mutations and monitors the\nevents fired on the node and a parent. The test will fall back to testing the\nnative feature, if `MutationEvent` is supported. You can run tests directly\nfrom this repo, [here](https://mfreed7.github.io/mutation-events-polyfill/test/test.html).\n\n## Improvements / Bugs\n\nIf you find issues with the polyfill, feel free to file them [here](https://github.com/mfreed7/mutation-events-polyfill/issues).\nEven better, if you would like to contribute to this polyfill,\nI'm happy to review [pull requests](https://github.com/mfreed7/mutation-events-polyfill/pulls).\nThanks in advance!\n","readmeFilename":"README.md"}