@@ -311,7 +311,8 @@ <h2 id="a-hrefinner-htmlinnerhtmla-mount-input-options"><a href="#inner-html">in
311311comes in handy for advanced use cases such as</ p >
312312< p > What's nice about these methods is that all renders go through the same
313313scheduling 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 'diffhtml';
339341
340342innerHTML(document.body, `
@@ -348,9 +350,8 @@ <h2 id="a-hrefouter-htmlouterhtmla-mount-input-options"><a href="#outer-html">ou
348350what has changed. Additionally updates the attributes of the parent. If the
349351element you're modifying has a parent, you may also change the element type,
350352but this isn't really recommended.</ p >
351- < p > Example:</ p >
352- < pre > < code class ="language-js "> outerHTML(document.body, '<body>Hello world</body>');</ 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, '<body>Hello world</body>');</ 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('<body>Hello world</body>');
380- // <body>Hello world</body></ 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('<body>Hello world</body>');
403+ // <body>Hello world</body></ 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)<
408414to "interpolate" or mix dynamic values with the HTML string content. This is
409415useful 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 "element" 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 <body>
@@ -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
426440below.</ 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 "element" 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
440450and 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'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('Start of render transaction:', 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
506518plugin</ 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.
568581Although "element" is used, the actual input can be of various input types
569582all representing an element (or many elements).</ p >
@@ -574,15 +587,8 @@ <h2 id="a-hrefremove-transition-stateremovetransitionstatea-statename-callback">
574587method will remove all transition callbacks. When invoked with the name
575588argument it will remove all transition state callbacks matching the name, and
576589so 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('attached');
582-
583- // Removes states by name and callback reference.
584- diff.removeTransitionState('attached', 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('attached');
615+
616+ // Removes states by name and callback reference.
617+ diff.removeTransitionState('attached', 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
606622a similar purpose to hyperscript's < code > h()</ code > and React's < code > createElement</ code > .</ p >
607- < p > Examples:</ p >
608- < pre > < code class ="language-js "> const attributes = {
609- id: 'test',
610- style: 'color: red',
611- };
612-
613- const childNodes = [
614- createTree('#text', null, 'Hello world'),
615- ];
616-
617- // Create a div Virtual Tree.
618- const div = createTree('div', 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: 'test',
649+ style: 'color: red',
650+ };
651+
652+ const childNodes = [
653+ createTree('#text', null, 'Hello world'),
654+ ];
655+
656+ // Create a div Virtual Tree.
657+ const div = createTree('div', 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
644662internal to diffHTML associated with your element. This is very useful for unit
645663testing and general cleanup when you're done with an element. Applications will
646664probably 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
0 commit comments