v2.0.0
Breaking Changes
v2.0.0
represents a significant departure from the previous API, based on feedback gathered from users using v1.x
.
Old (1.x
)
Previously, the list of files was specified as a JavaScript Array
of file
objects. We then initialize VanillaTreeViewer
and call render()
to render the component instances.
const files = [
{
path: 'foo/bar.js',
url: 'https://example.com/bar.js'
},
// ...
];
new VanillaTreeViewer('my-viewer', files, options).render();
New (2.0.0
)
The new approach allows us to define the list of files directly in the DOM (as an <ol>
element). A new renderAll()
static
method avoids the need for initializing a new instance:
<body>
<ol class='vtv'>
<li data-path="foo/bar.js" data-url="https://example.com/bar.js">
</li>
</ol>
<script>
document.addEventListener('DOMContentLoaded', function() {
VanillaTreeViewer.renderAll();
}, false);
</script>
</body>
See README
for more examples and documentation.
Other Changes
- The rendered component is now wrapped in a
div
with.vtv
and.vtv-wrapper
classes. (Previously.vtv
referred to an internal element, and is now called.vtv-root
) - Internal
highlight.js
dependency has been upgraded from10.4.1
->11.3.1
- Case is now preserved on file paths, so
data-path="README.md"
is rendered correctly asREADME.md
and notreadme.md
- Consistent case is now enforced on path directories. That means listing 2 files with
data-path="/alpha/beta.txt"
anddata-path="/ALPHA/gamma.txt"
will throw a validation error since/alpha
is ambiguously defined with two cases. - The header logo link now appends campaign params
Changelog
- Add campaign and update header logo link 2b5560c
- Upgrading
hljs
from10.4.1
->11.3.1
07bfcdb - Add validation to enforce unambiguous sub-paths 5e3f2fd
- Preserve original case on user-specified
path
eab91c4 - [Breaking Change] Parse structure and options from the DOM directly 26f0688
- Use
.vtv-root
instead of.vtv
for the top level CSS class name 27b5204 - [Breaking Change] Combine global options into file options 017e66f