Skip to content

Commit

Permalink
Add troubleshooting guide
Browse files Browse the repository at this point in the history
  • Loading branch information
craigbeck committed May 30, 2024
1 parent fb29b1c commit d7ff7b0
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 2 deletions.
4 changes: 2 additions & 2 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Jekyll has a dev server, which will auto-build the docs upon any changes to the
Setup:

```
cd derby-docs && bundle install
cd docs && bundle install
```

Run the dev server:
Expand All @@ -27,7 +27,7 @@ The site is viewable at `http://localhost:4000/derby/`.
One-time container creation:

```
docker run --name derby-docs-ruby -v "$(pwd)/docs:/derby-docs" -p 127.0.0.1:4000:4000 ruby:2.7 bash -c 'cd derby-docs && bundle install && bundle exec jekyll serve -H 0.0.0.0 -P 4000 --trace'
docker run --name derby-docs-ruby -v "$(pwd)/docs:/docs" -p 127.0.0.1:4000:4000 ruby:2.7 bash -c 'cd docs && bundle install && bundle exec jekyll serve -H 0.0.0.0 -P 4000 --trace'
```

Subsequently, to run the dev server:
Expand Down
68 changes: 68 additions & 0 deletions docs/troubleshooting.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
---
layout: default
title: Troubleshooting
---

# Troubleshooting

This guide covers common issues that you may run into as you use Derby. Feel free to contribute your own troubleshooting experience! :)

## Attaching bindings failed, because HTML structure does not match client rendering

When the page is loaded on the browser, the following error might be thrown in the console:

```
Attaching bindings failed, because HTML structure does not match client rendering
```

... along with the problematic view that is causing this issue. It can be tricky to understand what caused the error if you touched a bunch of files at the same time (JS, HTML, CSS) and being unsure what caused the problem in the first place. Turns out, it's always about the HTML structure.

When the page is rendered server side and is sent down to the client, Derby it will ensure that both HTML structures are exactly the same before attaching. If they don't match that is usually because the browser's parser attempts to gracefully handle invalid HTML that you may have introduced by mistake. For example, the following syntax is valid XML syntax but invalid HTML:

```jinja
<p>
<div>
</div>
</p>
```

Browsers will effectively turn this into:

```jinja
<p></p>
<div></div>
```

... according to the HTML rules set by W3:

> The P element represents a paragraph. It cannot contain block-level elements (including P itself). We discourage authors from using empty P elements. User agents should ignore empty P elements.
source: https://www.w3.org/TR/html401/struct/text.html#edef-P

The same goes for HTML tables where:

```jinja
<table>
<td></td>
</table>
```

... may be rendered by a browser as:

```jinja
<table>
<tbody>
<tr>
<td></td>
</tr>
</tbody>
</table>
```

There are many other ways where parsers will try to "fix" invalid HTML and cause Derby to fail attaching.

Here are a few common possibilities:
* invalid HTML (as illustrated above)
* sorting lists on in `init()` might cause the output to be non-deterministic (like alphabetizing / capitalization). Basically a data "bug" would end-up generated different HTML.
* putting links in links, which has undefined behavior in HTML
* inserting a conditional `<div>` such as `{{if thisIsTrue}}<div>stuff</div>{{/if}}` without restarting the server

0 comments on commit d7ff7b0

Please sign in to comment.