Skip to content

Commit b6352fa

Browse files
committed
Update documentation
1 parent 1a5d364 commit b6352fa

9 files changed

Lines changed: 167 additions & 126 deletions

File tree

docs/api.html

Lines changed: 64 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,8 @@ <h2 id="a-hrefinner-htmlinnerhtmla-mount-input-options"><a href="#inner-html">in
311311
comes in handy for advanced use cases such as</p>
312312
<p>What&#39;s nice about these methods is that all renders go through the same
313313
scheduling pipeline and VTrees are shared across all other renders.</p>
314-
<h3 id="arguments">Arguments</h3>
314+
<p><a name="inner-html-arguments"></a></p>
315+
<h3 id="a-hrefinner-html-argumentsuargumentsua"><a href="#inner-html-arguments"><u>Arguments</u></a></h3>
315316
<table>
316317
<thead>
317318
<tr>
@@ -334,7 +335,8 @@ <h3 id="arguments">Arguments</h3>
334335
</strong></td>
335336
</tr>
336337
</tbody></table>
337-
<h3 id="examples">Examples</h3>
338+
<p><a name="inner-html-examples"></a></p>
339+
<h3 id="a-hrefinner-html-examplesuexamplesua"><a href="#inner-html-examples"><u>Examples</u></a></h3>
338340
<pre><code class="language-js">import { innerHTML } from &#39;diffhtml&#39;;
339341

340342
innerHTML(document.body, `
@@ -348,9 +350,8 @@ <h2 id="a-hrefouter-htmlouterhtmla-mount-input-options"><a href="#outer-html">ou
348350
what has changed. Additionally updates the attributes of the parent. If the
349351
element you&#39;re modifying has a parent, you may also change the element type,
350352
but this isn&#39;t really recommended.</p>
351-
<p>Example:</p>
352-
<pre><code class="language-js">outerHTML(document.body, &#39;&lt;body&gt;Hello world&lt;/body&gt;&#39;);</code></pre>
353-
<h3 id="arguments-1">Arguments</h3>
353+
<p><a name="outer-html-arguments"></a></p>
354+
<h3 id="a-hrefouter-html-argumentsuargumentsua"><a href="#outer-html-arguments"><u>Arguments</u></a></h3>
354355
<table>
355356
<thead>
356357
<tr>
@@ -371,14 +372,15 @@ <h3 id="arguments-1">Arguments</h3>
371372
<td><ul><li><strong>tasks:</strong> An array of tasks to run. Can swap these out to modify the render flow.</li><li><strong>parser:</strong> Settings which influence the HTML parser.</li></ul></td>
372373
</tr>
373374
</tbody></table>
375+
<p><a name="outer-html-examples"></a></p>
376+
<h3 id="a-hrefouter-html-examplesuexamplesua"><a href="#outer-html-examples"><u>Examples</u></a></h3>
377+
<pre><code class="language-js">outerHTML(document.body, &#39;&lt;body&gt;Hello world&lt;/body&gt;&#39;);</code></pre>
374378
<p><a name="to-string"></a></p>
375379
<hr></hr>
376380
<h2 id="a-hrefto-stringtostringa-input-options"><a href="#to-string">toString</a> <strong><code>(input, options)</code></strong></h2>
377381
<p>Takes any valid input and returns a serialized string of XML/HTML markup.</p>
378-
<p>Example:</p>
379-
<pre><code class="language-js">toString(&#39;&lt;body&gt;Hello world&lt;/body&gt;&#39;);
380-
// &lt;body&gt;Hello world&lt;/body&gt;</code></pre>
381-
<h3 id="arguments-2">Arguments</h3>
382+
<p><a name="to-string-arguments"></a></p>
383+
<h3 id="a-hrefto-string-argumentsuargumentsua"><a href="#to-string-arguments"><u>Arguments</u></a></h3>
382384
<table>
383385
<thead>
384386
<tr>
@@ -395,6 +397,10 @@ <h3 id="arguments-2">Arguments</h3>
395397
<td><ul><li><strong>tasks:</strong> An array of tasks to run. Can swap these out to modify the render flow.</li><li><strong>parser:</strong> Settings which influence the HTML parser.</li></ul></td>
396398
</tr>
397399
</tbody></table>
400+
<p><a name="to-string-examples"></a></p>
401+
<h3 id="a-hrefto-string-examplesuexamplesua"><a href="#to-string-examples"><u>Examples</u></a></h3>
402+
<pre><code class="language-js">toString(&#39;&lt;body&gt;Hello world&lt;/body&gt;&#39;);
403+
// &lt;body&gt;Hello world&lt;/body&gt;</code></pre>
398404
<p><a name="html"></a></p>
399405
<hr></hr>
400406
<h2 id="a-hrefhtmlhtmla-markup"><a href="#html">html</a> <strong><code>(markup)</code></strong></h2>
@@ -408,8 +414,16 @@ <h2 id="a-hrefhtmlhtmla-markup"><a href="#html">html</a> <strong><code>(markup)<
408414
to &quot;interpolate&quot; or mix dynamic values with the HTML string content. This is
409415
useful when working with Web Components, DOM events,</p>
410416
<p>When you pass a single element and provide newlines and whitespace before and
411-
after it, like the example below, it will be automatically trimmed. If you
412-
provide multiple elements, the whitespace becomes</p>
417+
after it, like the examples below, they will be automatically trimmed out of the
418+
final tree. If you provide multiple elements, the whitespace becomes part of the
419+
tree.</p>
420+
<p><a name="html-arguments"></a></p>
421+
<h3 id="a-hrefhtml-argumentsuargumentsua"><a href="#html-arguments"><u>Arguments</u></a></h3>
422+
<p>The two required inputs are a reference element and new element to compare.
423+
Although &quot;element&quot; is used, the actual input can be of various input types
424+
all representing an element (or many elements).</p>
425+
<p><a name="html-examples"></a></p>
426+
<h3 id="a-hrefhtml-examplesuexamplesua"><a href="#html-examples"><u>Examples</u></a></h3>
413427
<p>A simple example of its usage along with interpolation.</p>
414428
<pre><code class="language-js">const vTree = html`
415429
&lt;body&gt;
@@ -424,10 +438,6 @@ <h2 id="a-hrefhtmlhtmla-markup"><a href="#html">html</a> <strong><code>(markup)<
424438
<a href="#examples" title="null">Examples</a>
425439
section
426440
below.</p>
427-
<h3 id="arguments-3">Arguments</h3>
428-
<p>The two required inputs are a reference element and new element to compare.
429-
Although &quot;element&quot; is used, the actual input can be of various input types
430-
all representing an element (or many elements).</p>
431441
<p><a name="use"></a></p>
432442
<hr></hr>
433443
<h2 id="a-hrefuseusea-middlewarefunction-or-middlewareobject"><a href="#use">use</a> <strong><code>(middlewareFunction or middlewareObject)</code></strong></h2>
@@ -439,7 +449,8 @@ <h2 id="a-hrefuseusea-middlewarefunction-or-middlewareobject"><a href="#use">use
439449
<a href="/middleware.html" title="null"><strong>Refer to the Middleware documentation for documentation on writing your own
440450
and find existing plugins.</strong></a>
441451
</p>
442-
<h3 id="arguments-4">Arguments</h3>
452+
<p><a name="use-arguments"></a></p>
453+
<h3 id="a-hrefuse-argumentsuargumentsua"><a href="#use-arguments"><u>Arguments</u></a></h3>
443454
<table>
444455
<thead>
445456
<tr>
@@ -456,7 +467,8 @@ <h3 id="arguments-4">Arguments</h3>
456467
<td>Use this when you don&#39;t care about the transaction start/stop, and want a cleaner way to monitor the VTree lifecycle. <ul><li>displayName</li><li>createNodeHook</li><li>createTreeHook</li><li>syncTreeHook</li><li>releaseHook</li><li>subscribe</li><li>unsubscribe</li></ul></td>
457468
</tr>
458469
</tbody></table>
459-
<h3 id="examples-1">Examples</h3>
470+
<p><a name="use-examples"></a></p>
471+
<h3 id="a-hrefuse-examplesuexamplesua"><a href="#use-examples"><u>Examples</u></a></h3>
460472
<h4 id="logging-the-start-of-a-render-transaction">Logging the start of a render transaction</h4>
461473
<pre><code class="language-js">function someTask(transaction) {
462474
console.log(&#39;Start of render transaction:&#39;, transaction);
@@ -505,7 +517,8 @@ <h2 id="a-hrefadd-transition-stateaddtransitionstatea-statename-callback"><a hre
505517
<a href="middleware.html#inline-transitions" title="null">diffhtml-inline-transitions
506518
plugin</a>
507519
.</p>
508-
<h3 id="arguments-5">Arguments</h3>
520+
<p><a name="add-transition-state-arguments"></a></p>
521+
<h3 id="a-hrefadd-transition-state-argumentsuargumentsua"><a href="#add-transition-state-arguments"><u>Arguments</u></a></h3>
509522
<table>
510523
<thead>
511524
<tr>
@@ -563,7 +576,7 @@ <h3 id="about-detachedreplaced-element-accuracy">About detached/replaced element
563576
<ol>
564577
<li>Remove the second element</li>
565578
</ol>
566-
<h3 id="arguments-6">Arguments</h3>
579+
<h3 id="arguments">Arguments</h3>
567580
<p>The two required inputs are a reference element and new element to compare.
568581
Although &quot;element&quot; is used, the actual input can be of various input types
569582
all representing an element (or many elements).</p>
@@ -574,15 +587,8 @@ <h2 id="a-hrefremove-transition-stateremovetransitionstatea-statename-callback">
574587
method will remove all transition callbacks. When invoked with the name
575588
argument it will remove all transition state callbacks matching the name, and
576589
so on for the callback.</p>
577-
<pre><code class="language-javascript">// Removes all registered transition states.
578-
diff.removeTransitionState();
579-
580-
// Removes states by name.
581-
diff.removeTransitionState(&#39;attached&#39;);
582-
583-
// Removes states by name and callback reference.
584-
diff.removeTransitionState(&#39;attached&#39;, callbackReference);</code></pre>
585-
<h3 id="arguments-7">Arguments</h3>
590+
<p><a name="remove-transition-state-arguments"></a></p>
591+
<h3 id="a-hrefremove-transition-state-argumentsuargumentsua"><a href="#remove-transition-state-arguments"><u>Arguments</u></a></h3>
586592
<table>
587593
<thead>
588594
<tr>
@@ -599,24 +605,23 @@ <h3 id="arguments-7">Arguments</h3>
599605
<td><em>Optional</em> Filter events to remove by the callback reference</td>
600606
</tr>
601607
</tbody></table>
608+
<p><a name="remove-transition-examples"></a></p>
609+
<h3 id="a-hrefremove-transition-examplesuexamplesua"><a href="#remove-transition-examples"><u>Examples</u></a></h3>
610+
<pre><code class="language-javascript">// Removes all registered transition states.
611+
diff.removeTransitionState();
612+
613+
// Removes states by name.
614+
diff.removeTransitionState(&#39;attached&#39;);
615+
616+
// Removes states by name and callback reference.
617+
diff.removeTransitionState(&#39;attached&#39;, callbackReference);</code></pre>
602618
<p><a name="create-tree"></a></p>
603619
<hr></hr>
604620
<h2 id="a-hrefcreate-treecreatetreea-nodename-attributes-childnodes"><a href="#create-tree">createTree</a> <strong><code>(nodeName, attributes, ...childNodes)</code></strong></h2>
605621
<p>Creates a Virtual Tree (VTree) which can be interpolated and rendered. This has
606622
a similar purpose to hyperscript&#39;s <code>h()</code> and React&#39;s <code>createElement</code>.</p>
607-
<p>Examples:</p>
608-
<pre><code class="language-js">const attributes = {
609-
id: &#39;test&#39;,
610-
style: &#39;color: red&#39;,
611-
};
612-
613-
const childNodes = [
614-
createTree(&#39;#text&#39;, null, &#39;Hello world&#39;),
615-
];
616-
617-
// Create a div Virtual Tree.
618-
const div = createTree(&#39;div&#39;, attributes, childNodes);</code></pre>
619-
<h3 id="arguments-8">Arguments</h3>
623+
<p><a name="create-tree-arguments"></a></p>
624+
<h3 id="a-hrefcreate-tree-argumentsuargumentsua"><a href="#create-tree-arguments"><u>Arguments</u></a></h3>
620625
<table>
621626
<thead>
622627
<tr>
@@ -637,14 +642,28 @@ <h3 id="arguments-8">Arguments</h3>
637642
<td>An array of child nodes, or a single element merged with any additional arguments</td>
638643
</tr>
639644
</tbody></table>
645+
<p><a name="create-tree-examples"></a></p>
646+
<h3 id="a-hrefcreate-tree-examplesuexamplesua"><a href="#create-tree-examples"><u>Examples</u></a></h3>
647+
<pre><code class="language-js">const attributes = {
648+
id: &#39;test&#39;,
649+
style: &#39;color: red&#39;,
650+
};
651+
652+
const childNodes = [
653+
createTree(&#39;#text&#39;, null, &#39;Hello world&#39;),
654+
];
655+
656+
// Create a div Virtual Tree.
657+
const div = createTree(&#39;div&#39;, attributes, childNodes);</code></pre>
640658
<p><a name="release"></a></p>
641659
<hr></hr>
642660
<h2 id="a-hrefreleasereleasea-mount"><a href="#release">release</a> <strong><code>(mount)</code></strong></h2>
643661
<p>Use this method if you need to clean up memory allocations and anything else
644662
internal to diffHTML associated with your element. This is very useful for unit
645663
testing and general cleanup when you&#39;re done with an element. Applications will
646664
probably not use this if the app lives as long as the tab.</p>
647-
<h3 id="arguments-9">Arguments</h3>
665+
<p><a name="release-arguments"></a></p>
666+
<h3 id="a-hrefrelease-argumentsuargumentsua"><a href="#release-arguments"><u>Arguments</u></a></h3>
648667
<table>
649668
<thead>
650669
<tr>
@@ -657,13 +676,6 @@ <h3 id="arguments-9">Arguments</h3>
657676
<td>Release memory and all internal references to the DOM node.</td>
658677
</tr>
659678
</tbody></table>
660-
<h4 id="domnode">domNode</h4>
661-
<p><em>Reference element.</em></p>
662-
<p>This argument is overloaded. Can be one of many types:</p>
663-
<ul>
664-
<li>HTML Element / DOM node (Used interchangeably)</li>
665-
<li>Virtual Tree Element (produced from <code>diff.html</code>)</li>
666-
</ul>
667679
<p><a name="internals"></a></p>
668680
<hr></hr>
669681
<h2 id="a-hrefinternalsinternalsa"><a href="#internals">Internals</a></h2>
@@ -849,15 +861,15 @@ <h4 id="example-3">Example</h4>
849861
</a>
850862

851863
<footer>
852-
<a href="https://twitter.com/tbranyen" style="text-decoration: none;">
864+
<a target="_blank" href="https://twitter.com/tbranyen" style="text-decoration: none;">
853865
<span>Created by @tbranyen</span>
854866
</a>
855867
<span style="margin: 0 15px;"> | </span>
856-
<a href="https://twitter.com/s0phinie" style="text-decoration: none;">
868+
<a target="_blank" href="https://twitter.com/s0phinie" style="text-decoration: none;">
857869
<span>Logo by @s0phinie</span>
858870
</a>
859871
<span style="margin-left: 15px;"> | </span>
860-
<a style="margin-left: 15px; text-decoration: none;" href="https://raw.githubusercontent.com/tbranyen/diffhtml/master/LICENSE"> MIT License</a>
872+
<a target="_blank" style="margin-left: 15px; text-decoration: none;" href="https://raw.githubusercontent.com/tbranyen/diffhtml/master/LICENSE"> MIT License</a>
861873
</footer>
862874
</layer>
863875

docs/components.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -425,15 +425,15 @@ <h2 id="a-hrefreact-compatreact-compata"><a href="#react-compat">React Compat</a
425425
</a>
426426

427427
<footer>
428-
<a href="https://twitter.com/tbranyen" style="text-decoration: none;">
428+
<a target="_blank" href="https://twitter.com/tbranyen" style="text-decoration: none;">
429429
<span>Created by @tbranyen</span>
430430
</a>
431431
<span style="margin: 0 15px;"> | </span>
432-
<a href="https://twitter.com/s0phinie" style="text-decoration: none;">
432+
<a target="_blank" href="https://twitter.com/s0phinie" style="text-decoration: none;">
433433
<span>Logo by @s0phinie</span>
434434
</a>
435435
<span style="margin-left: 15px;"> | </span>
436-
<a style="margin-left: 15px; text-decoration: none;" href="https://raw.githubusercontent.com/tbranyen/diffhtml/master/LICENSE"> MIT License</a>
436+
<a target="_blank" style="margin-left: 15px; text-decoration: none;" href="https://raw.githubusercontent.com/tbranyen/diffhtml/master/LICENSE"> MIT License</a>
437437
</footer>
438438
</layer>
439439

docs/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -418,15 +418,15 @@ <h3 id="a-hreftodomvcutodomvcua"><a href="#todomvc"><u>TodoMVC</u></a></h3>
418418
</a>
419419

420420
<footer>
421-
<a href="https://twitter.com/tbranyen" style="text-decoration: none;">
421+
<a target="_blank" href="https://twitter.com/tbranyen" style="text-decoration: none;">
422422
<span>Created by @tbranyen</span>
423423
</a>
424424
<span style="margin: 0 15px;"> | </span>
425-
<a href="https://twitter.com/s0phinie" style="text-decoration: none;">
425+
<a target="_blank" href="https://twitter.com/s0phinie" style="text-decoration: none;">
426426
<span>Logo by @s0phinie</span>
427427
</a>
428428
<span style="margin-left: 15px;"> | </span>
429-
<a style="margin-left: 15px; text-decoration: none;" href="https://raw.githubusercontent.com/tbranyen/diffhtml/master/LICENSE"> MIT License</a>
429+
<a target="_blank" style="margin-left: 15px; text-decoration: none;" href="https://raw.githubusercontent.com/tbranyen/diffhtml/master/LICENSE"> MIT License</a>
430430
</footer>
431431
</layer>
432432

docs/middleware.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -507,15 +507,15 @@ <h3 id="example-5">Example</h3>
507507
</a>
508508

509509
<footer>
510-
<a href="https://twitter.com/tbranyen" style="text-decoration: none;">
510+
<a target="_blank" href="https://twitter.com/tbranyen" style="text-decoration: none;">
511511
<span>Created by @tbranyen</span>
512512
</a>
513513
<span style="margin: 0 15px;"> | </span>
514-
<a href="https://twitter.com/s0phinie" style="text-decoration: none;">
514+
<a target="_blank" href="https://twitter.com/s0phinie" style="text-decoration: none;">
515515
<span>Logo by @s0phinie</span>
516516
</a>
517517
<span style="margin-left: 15px;"> | </span>
518-
<a style="margin-left: 15px; text-decoration: none;" href="https://raw.githubusercontent.com/tbranyen/diffhtml/master/LICENSE"> MIT License</a>
518+
<a target="_blank" style="margin-left: 15px; text-decoration: none;" href="https://raw.githubusercontent.com/tbranyen/diffhtml/master/LICENSE"> MIT License</a>
519519
</footer>
520520
</layer>
521521

docs/parser.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -465,15 +465,15 @@ <h2 id="a-hrefdynamic-valuesdynamic-valuesa"><a href="#dynamic-values">Dynamic v
465465
</a>
466466

467467
<footer>
468-
<a href="https://twitter.com/tbranyen" style="text-decoration: none;">
468+
<a target="_blank" href="https://twitter.com/tbranyen" style="text-decoration: none;">
469469
<span>Created by @tbranyen</span>
470470
</a>
471471
<span style="margin: 0 15px;"> | </span>
472-
<a href="https://twitter.com/s0phinie" style="text-decoration: none;">
472+
<a target="_blank" href="https://twitter.com/s0phinie" style="text-decoration: none;">
473473
<span>Logo by @s0phinie</span>
474474
</a>
475475
<span style="margin-left: 15px;"> | </span>
476-
<a style="margin-left: 15px; text-decoration: none;" href="https://raw.githubusercontent.com/tbranyen/diffhtml/master/LICENSE"> MIT License</a>
476+
<a target="_blank" style="margin-left: 15px; text-decoration: none;" href="https://raw.githubusercontent.com/tbranyen/diffhtml/master/LICENSE"> MIT License</a>
477477
</footer>
478478
</layer>
479479

docs/tools.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -323,15 +323,15 @@ <h2 id="a-hrefbabel-transformbabel-transform-optimize-buildsa"><a href="#babel-t
323323
</a>
324324

325325
<footer>
326-
<a href="https://twitter.com/tbranyen" style="text-decoration: none;">
326+
<a target="_blank" href="https://twitter.com/tbranyen" style="text-decoration: none;">
327327
<span>Created by @tbranyen</span>
328328
</a>
329329
<span style="margin: 0 15px;"> | </span>
330-
<a href="https://twitter.com/s0phinie" style="text-decoration: none;">
330+
<a target="_blank" href="https://twitter.com/s0phinie" style="text-decoration: none;">
331331
<span>Logo by @s0phinie</span>
332332
</a>
333333
<span style="margin-left: 15px;"> | </span>
334-
<a style="margin-left: 15px; text-decoration: none;" href="https://raw.githubusercontent.com/tbranyen/diffhtml/master/LICENSE"> MIT License</a>
334+
<a target="_blank" style="margin-left: 15px; text-decoration: none;" href="https://raw.githubusercontent.com/tbranyen/diffhtml/master/LICENSE"> MIT License</a>
335335
</footer>
336336
</layer>
337337

docs/transitions.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -354,15 +354,15 @@ <h3 id="a-hreftext-changedtext-changeda"><a href="#text-changed">Text changed</a
354354
</a>
355355

356356
<footer>
357-
<a href="https://twitter.com/tbranyen" style="text-decoration: none;">
357+
<a target="_blank" href="https://twitter.com/tbranyen" style="text-decoration: none;">
358358
<span>Created by @tbranyen</span>
359359
</a>
360360
<span style="margin: 0 15px;"> | </span>
361-
<a href="https://twitter.com/s0phinie" style="text-decoration: none;">
361+
<a target="_blank" href="https://twitter.com/s0phinie" style="text-decoration: none;">
362362
<span>Logo by @s0phinie</span>
363363
</a>
364364
<span style="margin-left: 15px;"> | </span>
365-
<a style="margin-left: 15px; text-decoration: none;" href="https://raw.githubusercontent.com/tbranyen/diffhtml/master/LICENSE"> MIT License</a>
365+
<a target="_blank" style="margin-left: 15px; text-decoration: none;" href="https://raw.githubusercontent.com/tbranyen/diffhtml/master/LICENSE"> MIT License</a>
366366
</footer>
367367
</layer>
368368

packages/diffhtml-website/components/layout.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,15 @@ module.exports = ({ path, page, pages, content }) => html`
5858
</a>
5959
6060
<footer>
61-
<a href="https://twitter.com/tbranyen" style="text-decoration: none;">
61+
<a target="_blank" href="https://twitter.com/tbranyen" style="text-decoration: none;">
6262
<span>Created by @tbranyen</span>
6363
</a>
6464
<span style="margin: 0 15px;"> | </span>
65-
<a href="https://twitter.com/s0phinie" style="text-decoration: none;">
65+
<a target="_blank" href="https://twitter.com/s0phinie" style="text-decoration: none;">
6666
<span>Logo by @s0phinie</span>
6767
</a>
6868
<span style="margin-left: 15px;"> | </span>
69-
<a style="margin-left: 15px; text-decoration: none;" href="https://raw.githubusercontent.com/tbranyen/diffhtml/master/LICENSE"> MIT License</a>
69+
<a target="_blank" style="margin-left: 15px; text-decoration: none;" href="https://raw.githubusercontent.com/tbranyen/diffhtml/master/LICENSE"> MIT License</a>
7070
</footer>
7171
</layer>
7272

0 commit comments

Comments
 (0)