Skip to content

Commit

Permalink
Initial *build()* support for Tabs.
Browse files Browse the repository at this point in the history
Issue #258.

␄
  • Loading branch information
Mike Castle committed Feb 27, 2024
1 parent 9b91a39 commit 42705fc
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions lib/widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -2154,6 +2154,33 @@ window.NexusHoratio.widget = (function widget() {
/** @param {string} name - Name for this instance. */
constructor(name) {
super(name, 'tabs');
this.on('build', this.#onBuild)
.on('destroy', this.#onDestroy);
}

#tablist

#resetContainer = () => {
this.container.innerHTML = '';
this.#tablist = document.createElement('tablist');
this.#tablist.role = 'tablist';
this.container.append(this.#tablist);
}

#onBuild = (...rest) => {
const me = 'onBuild';
this.logger.entered(me, rest);

this.#resetContainer();

this.logger.leaving(me);
}

#onDestroy = (...rest) => {
const me = 'onDestroy';
this.logger.entered(me, rest);

this.logger.leaving(me);
}

}
Expand All @@ -2169,6 +2196,23 @@ window.NexusHoratio.widget = (function widget() {
this.assertEqual(w.container.tagName, 'TABS', 'correct element');
}

testEmptyBuild() {
// Assemble
const w = new Tabs(this.id);

// Act
w.build();

// Assert
const expected = [
`^<tabs id="Tabs-[^-]*-${GUID}[^"]*">`,
'<tablist role="tablist">',
'</tablist>',
'</tabs>$',
].join('');
this.assertRegExp(w.container.outerHTML, RegExp(expected, 'u'));
}

}
/* eslint-enable */

Expand Down

0 comments on commit 42705fc

Please sign in to comment.