-
Notifications
You must be signed in to change notification settings - Fork 1
Conversation
WalkthroughWalkthroughThe changes introduce enhancements to the modification handling system within the Reactor framework. Key updates include the addition of unique identifiers for modifications, improved element state management, and the integration of a mutation observer for dynamic DOM monitoring. New utility functions and testing capabilities have also been added, enhancing the overall functionality and robustness of the system. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Reactor
participant MutationObserver
participant Element
User->>Reactor: Apply Modification
Reactor->>MutationObserver: Detach Observer
Reactor->>Element: Modify Content
Reactor->>MutationObserver: Attach Observer
MutationObserver->>Element: Observe Changes
MutationObserver->>Reactor: Handle Mutation
Reactor->>Element: Update State
TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (10)
- packages/reactor/interfaces.ts (2 hunks)
- packages/reactor/modifications.ts (1 hunks)
- packages/reactor/modifications/adjacentHTML.ts (2 hunks)
- packages/reactor/modifications/replaceAll.ts (5 hunks)
- packages/reactor/mutationObserver.ts (2 hunks)
- packages/reactor/reactor.ts (5 hunks)
- packages/reactor/tests/modifications.test.ts (15 hunks)
- packages/reactor/tests/mutation.test.ts (1 hunks)
- packages/reactor/tests/test.utils.ts (1 hunks)
- packages/reactor/utils.ts (1 hunks)
Additional context used
GitHub Check: vitest_run
packages/reactor/tests/modifications.test.ts
[failure] 206-206: tests/modifications.test.ts > Utils > applyModification > should unapply from wikipedia
AssertionError: expected '<p mocksi-id="lybmz6g6" mocksi-modifi…' to be 'The office of the "President of th…' // Object.is equality
- Expected
- Received
The office of the "President of the People's Committee" (ประธานคณะกรรมการราษฎร), later changed to "Prime Minister of Siam" (นายกรัฐมนตรีสยาม), was first created in the Temporary Constitution of 1932. The office was modeled after the prime minister of the United Kingdom, as Siam became a parliamentary democracy in 1932 after a bloodless revolution. However, the idea of a separate head of government in Russia is not new.
. However, the idea of a separate head of government in Thailand is not new.ประธานคณะกรรมการราษฎร), later changed to "Prime Minister of Siam" (นายกรัฐมนตรีสยาม), was first created in the Temporary Constitution of 1932. The office was modeled after the prime minister of the United Kingdom, as Siam became a parliamentary democracy in 1932 after a bloodless revolution. However, the idea of a separate head of government in Russia is not new.
❯ tests/modifications.test.ts:206:30
Additional comments not posted (59)
packages/reactor/tests/test.utils.ts (2)
1-1
: LGTM!The import statement is correct and necessary for type definitions.
The code changes are approved.
3-17
: LGTM!The
extendExpect
function is correctly implemented and adds useful functionality for testing by extending theexpect
object with a custom matchertoMatchIgnoringMocksiTags
.The code changes are approved.
packages/reactor/utils.ts (2)
Line range hint
1-14
: LGTM!The
parseRequest
function is correctly implemented and handles errors appropriately by logging them and throwing a new error.The code changes are approved.
15-23
: LGTM!The
generateRandomString
function is correctly implemented and provides useful functionality for generating random strings of a specified length using lowercase letters and digits.The code changes are approved.
packages/reactor/modifications/adjacentHTML.ts (4)
4-4
: LGTM!The
elementId
property replaces theelement
property and aligns with the new approach of using ID-based references.The code changes are approved.
15-19
: LGTM!The constructor has been updated to use
this.addModifiedElement(element)
and setthis.elementId
, enhancing the encapsulation of element management.The code changes are approved.
23-27
: LGTM!The
apply
method has been updated to handle multiple elements and track their old state, enhancing the robustness of theapply
operation.The code changes are approved.
31-36
: LGTM!The
unapply
method has been updated to handle multiple elements and restore their old state, enhancing the robustness of theunapply
operation.The code changes are approved.
packages/reactor/tests/mutation.test.ts (6)
1-4
: LGTM!The import statements are correct and necessary for the tests.
The code changes are approved.
6-6
: LGTM!The
extendExpect
function is correctly called to extend theexpect
function.The code changes are approved.
8-8
: LGTM!The
describe
block is correctly used to group related tests.The code changes are approved.
13-21
: LGTM!The
beforeEach
block is correctly used to set up the test environment before each test.The code changes are approved.
23-44
: LGTM!The
it
block is correctly used to test the handling of an added mutation.The code changes are approved.
46-67
: LGTM!The
it
block is correctly used to test the handling of undoing after an added mutation.The code changes are approved.
packages/reactor/interfaces.ts (11)
1-1
: LGTM!The import statement is correct and necessary for the new functionality.
The code changes are approved.
55-55
: LGTM!The new property
uuid
is correctly added to the class.The code changes are approved.
67-77
: LGTM!The
addModifiedElement
method is correctly implemented to add a modified element.The code changes are approved.
79-86
: LGTM!The
removeModifiedElement
method is correctly implemented to remove a modified element.The code changes are approved.
88-90
: LGTM!The
getModifiedElement
method is correctly implemented to get a modified element by itsmocksi-id
.The code changes are approved.
92-96
: LGTM!The
getModifiedElements
method is correctly implemented to get all modified elements.The code changes are approved.
101-104
: LGTM!The
modifiedElementRemoved
method is correctly implemented to check if a modification is no longer needed.The code changes are approved.
106-108
: LGTM!The
getMocksiId
method is correctly implemented to get themocksi-id
of an element.The code changes are approved.
110-112
: LGTM!The
setElementState
method is correctly implemented to set the state of an element.The code changes are approved.
114-116
: LGTM!The
getElementState
method is correctly implemented to get the state of an element.The code changes are approved.
118-120
: LGTM!The
removeElementState
method is correctly implemented to remove the state of an element.The code changes are approved.
packages/reactor/mutationObserver.ts (7)
1-3
: LGTM!The import statements are correct and necessary for the new functionality.
The code changes are approved.
6-11
: LGTM!The new property
reactor
and the constructor are correctly implemented.The code changes are approved.
28-42
: LGTM!The
handleMutation
method is correctly implemented to handle mutations in the DOM.The code changes are approved.
44-68
: LGTM!The
walkAddedElements
method is correctly implemented to walk through added elements.The code changes are approved.
70-92
: LGTM!The
walkRemovedElements
method is correctly implemented to walk through removed elements.The code changes are approved.
94-107
: LGTM!The
removeModifiedElement
method is correctly implemented to remove a modified element.The code changes are approved.
110-124
: LGTM!The
printNode
function is correctly implemented to print a node.The code changes are approved.
packages/reactor/modifications.ts (2)
Line range hint
140-198
: LGTM!The function is correctly implemented, handling different modification types appropriately.
The code changes are approved.
200-209
: LGTM!The function is correctly implemented, handling both selector and XPath cases appropriately.
The code changes are approved.
packages/reactor/modifications/replaceAll.ts (7)
7-14
: LGTM!The constructor is correctly implemented, initializing the
MutationObserver
appropriately.The code changes are approved.
18-29
: LGTM!The function is correctly implemented, applying the modification and starting the observation appropriately.
The code changes are approved.
Line range hint
33-57
: LGTM!The function is correctly implemented, disconnecting the observer and reverting the changes appropriately.
The code changes are approved.
58-80
: LGTM!The function is correctly implemented, handling mutations and updating the changes array appropriately.
The code changes are approved.
82-91
: LGTM!The function is correctly implemented, removing changes related to a specific element appropriately.
The code changes are approved.
95-98
: LGTM!The type is correctly defined, reflecting the structure of a tree change appropriately.
The code changes are approved.
Line range hint
159-204
: LGTM!The function is correctly implemented, replacing text in a node based on a pattern appropriately.
The code changes are approved.
packages/reactor/reactor.ts (3)
23-29
: LGTM!The constructor is correctly implemented, initializing the
mutationObserver
appropriately.The code changes are approved.
53-55
: LGTM!The function is correctly implemented, attaching the
Reactor
to the document and applying modifications appropriately.The code changes are approved.
157-169
: LGTM!The function is correctly implemented, pushing a modification request to the stack and applying it appropriately.
The code changes are approved.
packages/reactor/tests/modifications.test.ts (15)
2-2
: LGTM!The import statement for
extendExpect
is correctly added.The code changes are approved.
7-7
: LGTM!The function call to
extendExpect(expect);
is correctly added to extend the expect functionality.The code changes are approved.
Line range hint
51-56
: LGTM!The test case is correctly modified to use
toMatchIgnoringMocksiTags
instead oftoBe
for more flexible matching.The code changes are approved.
Line range hint
66-71
: LGTM!The test case is correctly modified to use
toMatchIgnoringMocksiTags
instead oftoBe
for more flexible matching.The code changes are approved.
Line range hint
81-85
: LGTM!The test case is correctly modified to use
toMatchIgnoringMocksiTags
instead oftoBe
for more flexible matching.The code changes are approved.
Line range hint
95-99
: LGTM!The test case is correctly modified to use
toMatchIgnoringMocksiTags
instead oftoBe
for more flexible matching.The code changes are approved.
Line range hint
112-116
: LGTM!The test case is correctly modified to use
toMatchIgnoringMocksiTags
instead oftoBe
for more flexible matching.The code changes are approved.
Line range hint
129-133
: LGTM!The test case is correctly modified to use
toMatchIgnoringMocksiTags
instead oftoBe
for more flexible matching.The code changes are approved.
Line range hint
147-151
: LGTM!The test case is correctly modified to use
toMatchIgnoringMocksiTags
instead oftoBe
for more flexible matching.The code changes are approved.
178-191
: LGTM!The new test case is well-structured and effectively validates the
applyModification
method with Wikipedia-style content.The code changes are approved.
Line range hint
216-221
: LGTM!The test case is correctly modified to use
toMatchIgnoringMocksiTags
instead oftoBe
for more flexible matching.The code changes are approved.
Line range hint
234-239
: LGTM!The test case is correctly modified to use
toMatchIgnoringMocksiTags
instead oftoBe
for more flexible matching.The code changes are approved.
Line range hint
249-254
: LGTM!The test case is correctly modified to use
toMatchIgnoringMocksiTags
instead oftoBe
for more flexible matching.The code changes are approved.
Line range hint
267-272
: LGTM!The test case is correctly modified to use
toMatchIgnoringMocksiTags
instead oftoBe
for more flexible matching.The code changes are approved.
Line range hint
432-437
: LGTM!The test case is correctly modified to use
toMatchIgnoringMocksiTags
instead oftoBe
for more flexible matching.The code changes are approved.
it("should unapply from wikipedia", async() => { | ||
const modification: Modification = { | ||
action: "replaceAll", | ||
content: "/Thailand/Russia/", | ||
}; | ||
|
||
const element = doc.createElement("p"); | ||
element.innerHTML = "<p>The office of the \"President of the <a href=\"/wiki/People%27s_Committee_of_Siam\" title=\"People's Committee of Siam\">People's Committee</a>\" (<span title=\"Thai-language text\"><span lang=\"th\">ประธานคณะกรรมการราษฎร</span></span>), later changed to \"Prime Minister of Siam\" (<span title=\"Thai-language text\"><span lang=\"th\">นายกรัฐมนตรีสยาม</span></span>), was first created in the <a href=\"/wiki/Constitution_of_Thailand#1932_Temporary_Charter\" title=\"Constitution of Thailand\">Temporary Constitution of 1932</a>. The office was modeled after the <a href=\"/wiki/Prime_Minister_of_the_United_Kingdom\" title=\"Prime Minister of the United Kingdom\">prime minister of the United Kingdom</a>, as Siam became a <a href=\"/wiki/Parliamentary_democracy\" class=\"mw-redirect\" title=\"Parliamentary democracy\">parliamentary democracy</a> in 1932 after a <a href=\"/wiki/Siamese_revolution_of_1932\" title=\"Siamese revolution of 1932\">bloodless revolution</a>. However, the idea of a separate head of government in Thailand is not new.</p>" | ||
doc.body.appendChild(element); | ||
|
||
const modifications = await applyModification(doc.body, modification, doc); | ||
modifications.unapply(); | ||
|
||
expect(element.innerHTML).toBe("<p>The office of the \"President of the <a href=\"/wiki/People%27s_Committee_of_Siam\" title=\"People's Committee of Siam\">People's Committee</a>\" (<span title=\"Thai-language text\"><span lang=\"th\">ประธานคณะกรรมการราษฎร</span></span>), later changed to \"Prime Minister of Siam\" (<span title=\"Thai-language text\"><span lang=\"th\">นายกรัฐมนตรีสยาม</span></span>), was first created in the <a href=\"/wiki/Constitution_of_Thailand#1932_Temporary_Charter\" title=\"Constitution of Thailand\">Temporary Constitution of 1932</a>. The office was modeled after the <a href=\"/wiki/Prime_Minister_of_the_United_Kingdom\" title=\"Prime Minister of the United Kingdom\">prime minister of the United Kingdom</a>, as Siam became a <a href=\"/wiki/Parliamentary_democracy\" class=\"mw-redirect\" title=\"Parliamentary democracy\">parliamentary democracy</a> in 1932 after a <a href=\"/wiki/Siamese_revolution_of_1932\" title=\"Siamese revolution of 1932\">bloodless revolution</a>. However, the idea of a separate head of government in Russia is not new.</p>"); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix the test case failure.
The new test case is well-structured but fails due to additional attributes in the modified content.
Apply this diff to fix the test case failure:
- expect(element.innerHTML).toBe("<p>The office of the \"President of the <a href=\"/wiki/People%27s_Committee_of_Siam\" title=\"People's Committee of Siam\">People's Committee</a>\" (<span title=\"Thai-language text\"><span lang=\"th\">ประธานคณะกรรมการราษฎร</span></span>), later changed to \"Prime Minister of Siam\" (<span title=\"Thai-language text\"><span lang=\"th\">นายกรัฐมนตรีสยาม</span></span>), was first created in the <a href=\"/wiki/Constitution_of_Thailand#1932_Temporary_Charter\" title=\"Constitution of Thailand\">Temporary Constitution of 1932</a>. The office was modeled after the <a href=\"/wiki/Prime_Minister_of_the_United_Kingdom\" title=\"Prime Minister of the United Kingdom\">prime minister of the United Kingdom</a>, as Siam became a <a href=\"/wiki/Parliamentary_democracy\" class=\"mw-redirect\" title=\"Parliamentary democracy\">parliamentary democracy</a> in 1932 after a <a href=\"/wiki/Siamese_revolution_of_1932\" title=\"Siamese revolution of 1932\">bloodless revolution</a>. However, the idea of a separate head of government in Russia is not new.</p>");
+ expect(element.innerHTML).toMatchIgnoringMocksiTags("<p>The office of the \"President of the <a href=\"/wiki/People%27s_Committee_of_Siam\" title=\"People's Committee of Siam\">People's Committee</a>\" (<span title=\"Thai-language text\"><span lang=\"th\">ประธานคณะกรรมการราษฎร</span></span>), later changed to \"Prime Minister of Siam\" (<span title=\"Thai-language text\"><span lang=\"th\">นายกรัฐมนตรีสยาม</span></span>), was first created in the <a href=\"/wiki/Constitution_of_Thailand#1932_Temporary_Charter\" title=\"Constitution of Thailand\">Temporary Constitution of 1932</a>. The office was modeled after the <a href=\"/wiki/Prime_Minister_of_the_United_Kingdom\" title=\"Prime Minister of the United Kingdom\">prime minister of the United Kingdom</a>, as Siam became a <a href=\"/wiki/Parliamentary_democracy\" class=\"mw-redirect\" title=\"Parliamentary democracy\">parliamentary democracy</a> in 1932 after a <a href=\"/wiki/Siamese_revolution_of_1932\" title=\"Siamese revolution of 1932\">bloodless revolution</a>. However, the idea of a separate head of government in Russia is not new.</p>");
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
it("should unapply from wikipedia", async() => { | |
const modification: Modification = { | |
action: "replaceAll", | |
content: "/Thailand/Russia/", | |
}; | |
const element = doc.createElement("p"); | |
element.innerHTML = "<p>The office of the \"President of the <a href=\"/wiki/People%27s_Committee_of_Siam\" title=\"People's Committee of Siam\">People's Committee</a>\" (<span title=\"Thai-language text\"><span lang=\"th\">ประธานคณะกรรมการราษฎร</span></span>), later changed to \"Prime Minister of Siam\" (<span title=\"Thai-language text\"><span lang=\"th\">นายกรัฐมนตรีสยาม</span></span>), was first created in the <a href=\"/wiki/Constitution_of_Thailand#1932_Temporary_Charter\" title=\"Constitution of Thailand\">Temporary Constitution of 1932</a>. The office was modeled after the <a href=\"/wiki/Prime_Minister_of_the_United_Kingdom\" title=\"Prime Minister of the United Kingdom\">prime minister of the United Kingdom</a>, as Siam became a <a href=\"/wiki/Parliamentary_democracy\" class=\"mw-redirect\" title=\"Parliamentary democracy\">parliamentary democracy</a> in 1932 after a <a href=\"/wiki/Siamese_revolution_of_1932\" title=\"Siamese revolution of 1932\">bloodless revolution</a>. However, the idea of a separate head of government in Thailand is not new.</p>" | |
doc.body.appendChild(element); | |
const modifications = await applyModification(doc.body, modification, doc); | |
modifications.unapply(); | |
expect(element.innerHTML).toBe("<p>The office of the \"President of the <a href=\"/wiki/People%27s_Committee_of_Siam\" title=\"People's Committee of Siam\">People's Committee</a>\" (<span title=\"Thai-language text\"><span lang=\"th\">ประธานคณะกรรมการราษฎร</span></span>), later changed to \"Prime Minister of Siam\" (<span title=\"Thai-language text\"><span lang=\"th\">นายกรัฐมนตรีสยาม</span></span>), was first created in the <a href=\"/wiki/Constitution_of_Thailand#1932_Temporary_Charter\" title=\"Constitution of Thailand\">Temporary Constitution of 1932</a>. The office was modeled after the <a href=\"/wiki/Prime_Minister_of_the_United_Kingdom\" title=\"Prime Minister of the United Kingdom\">prime minister of the United Kingdom</a>, as Siam became a <a href=\"/wiki/Parliamentary_democracy\" class=\"mw-redirect\" title=\"Parliamentary democracy\">parliamentary democracy</a> in 1932 after a <a href=\"/wiki/Siamese_revolution_of_1932\" title=\"Siamese revolution of 1932\">bloodless revolution</a>. However, the idea of a separate head of government in Russia is not new.</p>"); | |
}); | |
it("should unapply from wikipedia", async() => { | |
const modification: Modification = { | |
action: "replaceAll", | |
content: "/Thailand/Russia/", | |
}; | |
const element = doc.createElement("p"); | |
element.innerHTML = "<p>The office of the \"President of the <a href=\"/wiki/People%27s_Committee_of_Siam\" title=\"People's Committee of Siam\">People's Committee</a>\" (<span title=\"Thai-language text\"><span lang=\"th\">ประธานคณะกรรมการราษฎร</span></span>), later changed to \"Prime Minister of Siam\" (<span title=\"Thai-language text\"><span lang=\"th\">นายกรัฐมนตรีสยาม</span></span>), was first created in the <a href=\"/wiki/Constitution_of_Thailand#1932_Temporary_Charter\" title=\"Constitution of Thailand\">Temporary Constitution of 1932</a>. The office was modeled after the <a href=\"/wiki/Prime_Minister_of_the_United_Kingdom\" title=\"Prime Minister of the United Kingdom\">prime minister of the United Kingdom</a>, as Siam became a <a href=\"/wiki/Parliamentary_democracy\" class=\"mw-redirect\" title=\"Parliamentary democracy\">parliamentary democracy</a> in 1932 after a <a href=\"/wiki/Siamese_revolution_of_1932\" title=\"Siamese revolution of 1932\">bloodless revolution</a>. However, the idea of a separate head of government in Thailand is not new.</p>" | |
doc.body.appendChild(element); | |
const modifications = await applyModification(doc.body, modification, doc); | |
modifications.unapply(); | |
expect(element.innerHTML).toMatchIgnoringMocksiTags("<p>The office of the \"President of the <a href=\"/wiki/People%27s_Committee_of_Siam\" title=\"People's Committee of Siam\">People's Committee</a>\" (<span title=\"Thai-language text\"><span lang=\"th\">ประธานคณะกรรมการราษฎร</span></span>), later changed to \"Prime Minister of Siam\" (<span title=\"Thai-language text\"><span lang=\"th\">นายกรัฐมนตรีสยาม</span></span>), was first created in the <a href=\"/wiki/Constitution_of_Thailand#1932_Temporary_Charter\" title=\"Constitution of Thailand\">Temporary Constitution of 1932</a>. The office was modeled after the <a href=\"/wiki/Prime_Minister_of_the_United_Kingdom\" title=\"Prime Minister of the United Kingdom\">prime minister of the United Kingdom</a>, as Siam became a <a href=\"/wiki/Parliamentary_democracy\" class=\"mw-redirect\" title=\"Parliamentary democracy\">parliamentary democracy</a> in 1932 after a <a href=\"/wiki/Siamese_revolution_of_1932\" title=\"Siamese revolution of 1932\">bloodless revolution</a>. However, the idea of a separate head of government in Russia is not new.</p>"); | |
}); |
Tools
GitHub Check: vitest_run
[failure] 206-206: tests/modifications.test.ts > Utils > applyModification > should unapply from wikipedia
AssertionError: expected '<p mocksi-id="lybmz6g6" mocksi-modifi…' to be 'The office of the "President of th…' // Object.is equality
- Expected
- Received
The office of the "President of the People's Committee" (ประธานคณะกรรมการราษฎร), later changed to "Prime Minister of Siam" (นายกรัฐมนตรีสยาม), was first created in the Temporary Constitution of 1932. The office was modeled after the prime minister of the United Kingdom, as Siam became a parliamentary democracy in 1932 after a bloodless revolution. However, the idea of a separate head of government in Russia is not new.
. However, the idea of a separate head of government in Thailand is not new.ประธานคณะกรรมการราษฎร), later changed to "Prime Minister of Siam" (นายกรัฐมนตรีสยาม), was first created in the Temporary Constitution of 1932. The office was modeled after the prime minister of the United Kingdom, as Siam became a parliamentary democracy in 1932 after a bloodless revolution. However, the idea of a separate head of government in Russia is not new.
❯ tests/modifications.test.ts:206:30
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (3)
- packages/reactor/modifications/replaceAll.ts (5 hunks)
- packages/reactor/tests/modifications.test.ts (15 hunks)
- packages/reactor/tests/test.utils.ts (1 hunks)
Files skipped from review as they are similar to previous changes (3)
- packages/reactor/modifications/replaceAll.ts
- packages/reactor/tests/modifications.test.ts
- packages/reactor/tests/test.utils.ts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fantastic work! 🙌🔥
Note: I saw some duplication on mutationObserver, but I suggest we hold off on any further refactoring until Drew and Kayla complete their QA. This will help us minimize risks as we approach the beta launch 🚢
this.element.insertAdjacentHTML(this.position, this.newValue); | ||
|
||
// TODO - highlighting | ||
for (const element of this.getModifiedElements()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: this apply and unapply func look very similar... No idea how to remove the duplication though, so just leaving this as a note, feel free to ignore 😄
this.observer.disconnect(); | ||
|
||
for (const mutation of mutations) { | ||
if (mutation.type === "childList") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: an early return/continue would make this code a tiny bit neater
|
||
constructor(doc: Document, element: Element, content: string) { | ||
super(doc); | ||
this.element = element; | ||
this.content = content; | ||
|
||
this.observer = new MutationObserver(this.handleMutation.bind(this)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Major changes:
Summary by CodeRabbit
New Features
uuid
property.MutationObserver
for dynamic updates.Bug Fixes
Documentation