-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #32 from chinedufn/web-sys
Migrate to web-sys
- Loading branch information
Showing
21 changed files
with
405 additions
and
229 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Design of `percy` | ||
|
||
This section is intended to be a deep dive into how `percy`'s different internal pieces work today. |
42 changes: 42 additions & 0 deletions
42
book/src/contributing/internal-design/sibling-text-nodes.md
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Sibling text nodes | ||
|
||
If a browser sees two text nodes next to each other it will combine them into one. | ||
|
||
For example, when you have a component that looks like this: | ||
|
||
```rust | ||
let sibling_text_nodes = html! { <div> {"Hello" "World" } </div> }; | ||
``` | ||
|
||
A browser will end up turning it into something like this | ||
|
||
```html | ||
<div>Hello World</div> | ||
``` | ||
|
||
The `textContent` of the div in the browser is now "Hello World". | ||
|
||
If we did not work around this behavior we wouldn't be able to patch the DOM when two text nodes are next to each other. | ||
We'd have no way of knowing how to find the original, individual strings that we wanted to render. | ||
|
||
To get around this here's what we actually end up rendering: | ||
|
||
```html | ||
<div>Hello <!--ptns-->World</div> | ||
``` | ||
|
||
Note the new `<!--ptns-->` comment node. Here's what `virtual_dom_rs`'s `createElement()` method ended up doing: | ||
|
||
1. Saw the "Hello" virtual text and appended a real Text node into the real DOM `<div>` | ||
2. Saw the "World" virtual text and saw that the previous element was also a virtual text node | ||
3. Appended a `<!--ptns>` real comment element into the `<div>` | ||
4. Appended a real "World" Text node into the `<div>` | ||
|
||
If we later wanted to patch the DOM with a new component | ||
|
||
``` | ||
let sibling_text_nodes = html! { <div> {"Hello" "NEW_TEXT" } </div> }; | ||
``` | ||
|
||
Our `virtual_dom_rs` patch function would be able to find the old "World" text node since we've ensured that it | ||
did not get merged in with any other text nodes. |
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
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
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
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.