tablefilter 0.7.12 → 0.7.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/starter.html +2 -2
- package/dist/tablefilter/tablefilter.js +2 -2
- package/dist/tablefilter/tf-1-8fd757943bbcb7f745f1.js +1 -0
- package/dist/tablefilter/tf-1-c602f0c7f884cadf2080.js +1 -0
- package/dist/tablefilter.cjs.js +70 -11
- package/dist/tablefilter.esm.js +70 -11
- package/dist/tablefilter.umd.js +70 -11
- package/package.json +8 -8
- package/src/components/tf-no-results.js +94 -0
- package/src/modules/noResults.js +83 -21
- package/src/tablefilter.js +15 -0
- package/dist/tablefilter/tf-1-50952b085af8d40b6e1e.js +0 -1
- package/dist/tablefilter/tf-1-545915aa28e08079de1d.js +0 -1
package/dist/tablefilter.umd.js
CHANGED
|
@@ -17717,6 +17717,7 @@
|
|
|
17717
17717
|
};
|
|
17718
17718
|
//#endregion
|
|
17719
17719
|
//#region src/modules/noResults.js
|
|
17720
|
+
var TOGGLE_EVENTS = ["initialized", "after-filtering"];
|
|
17720
17721
|
/**
|
|
17721
17722
|
* UI when filtering yields no matches
|
|
17722
17723
|
* @export
|
|
@@ -17740,18 +17741,18 @@
|
|
|
17740
17741
|
* Custom container DOM element
|
|
17741
17742
|
* @type {DOMElement}
|
|
17742
17743
|
*/
|
|
17743
|
-
this.customContainer =
|
|
17744
|
+
this.customContainer = f.custom_container && typeof f.custom_container.appendChild === "function" ? f.custom_container : null;
|
|
17744
17745
|
/**
|
|
17745
17746
|
* ID of custom container element
|
|
17746
17747
|
* @type {String}
|
|
17747
17748
|
*/
|
|
17748
17749
|
this.customContainerId = defaultsStr(f.custom_container_id, null);
|
|
17749
17750
|
/**
|
|
17750
|
-
*
|
|
17751
|
+
* True when a container element is present or a container id is set
|
|
17751
17752
|
* @type {Boolean}
|
|
17752
17753
|
* @private
|
|
17753
17754
|
*/
|
|
17754
|
-
this.isExternal =
|
|
17755
|
+
this.isExternal = Boolean(this.customContainer) || Boolean(this.customContainerId);
|
|
17755
17756
|
/**
|
|
17756
17757
|
* Css class assigned to container element
|
|
17757
17758
|
* @type {String}
|
|
@@ -17782,23 +17783,67 @@
|
|
|
17782
17783
|
* @type {Function}
|
|
17783
17784
|
*/
|
|
17784
17785
|
this.onAfterHide = defaultsFn(f.on_after_hide_msg, EMPTY_FN);
|
|
17786
|
+
/**
|
|
17787
|
+
* Subscribed toggle handler
|
|
17788
|
+
* @type {Function|null}
|
|
17789
|
+
* @private
|
|
17790
|
+
*/
|
|
17791
|
+
this.boundToggle = null;
|
|
17785
17792
|
}
|
|
17786
17793
|
/**
|
|
17787
17794
|
* Initializes NoResults instance
|
|
17788
17795
|
*/
|
|
17789
17796
|
init() {
|
|
17790
17797
|
if (this.initialized) return;
|
|
17791
|
-
let
|
|
17792
|
-
|
|
17798
|
+
let targetEl = this.isExternal ? this.customContainer || elm(this.customContainerId) : null;
|
|
17799
|
+
if (this.canUseCE(targetEl)) this.initCE(targetEl);
|
|
17800
|
+
else this.initLegacy(targetEl);
|
|
17801
|
+
this.boundToggle = () => this.toggle();
|
|
17802
|
+
this.emitter.on(TOGGLE_EVENTS, this.boundToggle);
|
|
17803
|
+
/** @inherited */
|
|
17804
|
+
this.initialized = true;
|
|
17805
|
+
}
|
|
17806
|
+
/**
|
|
17807
|
+
* Whether the feature renders through `<tf-no-results>`.
|
|
17808
|
+
* @param {DOMElement} targetEl Resolved external container, if any
|
|
17809
|
+
* @returns {Boolean} True when the registered element exposes `setText`
|
|
17810
|
+
* and no external container is configured, or the container resolves
|
|
17811
|
+
* @private
|
|
17812
|
+
*/
|
|
17813
|
+
canUseCE(targetEl) {
|
|
17814
|
+
const NoResultsElement = typeof customElements === "undefined" ? null : customElements.get("tf-no-results");
|
|
17815
|
+
return Boolean(NoResultsElement) && typeof NoResultsElement.prototype.setText === "function" && (!this.isExternal || Boolean(targetEl && typeof targetEl.appendChild === "function"));
|
|
17816
|
+
}
|
|
17817
|
+
/**
|
|
17818
|
+
* Initialize using the <tf-no-results> custom element
|
|
17819
|
+
* @param {DOMElement} targetEl External container element
|
|
17820
|
+
* @private
|
|
17821
|
+
*/
|
|
17822
|
+
initCE(targetEl) {
|
|
17823
|
+
const host = document.createElement("tf-no-results");
|
|
17824
|
+
host.className = this.cssClass;
|
|
17825
|
+
host.setText("");
|
|
17826
|
+
host.innerHTML = sanitizeHtml(this.content);
|
|
17827
|
+
if (this.isExternal) targetEl.appendChild(host);
|
|
17828
|
+
else {
|
|
17829
|
+
const dom = this.tf.dom();
|
|
17830
|
+
dom.parentNode.insertBefore(host, dom.nextSibling);
|
|
17831
|
+
}
|
|
17832
|
+
this.cont = host;
|
|
17833
|
+
}
|
|
17834
|
+
/**
|
|
17835
|
+
* Initialize using the legacy div container
|
|
17836
|
+
* @param {DOMElement} targetEl External container element
|
|
17837
|
+
* @private
|
|
17838
|
+
*/
|
|
17839
|
+
initLegacy(targetEl) {
|
|
17840
|
+
let target = targetEl || this.tf.dom();
|
|
17793
17841
|
let cont = createElm("div");
|
|
17794
17842
|
cont.className = this.cssClass;
|
|
17795
17843
|
cont.innerHTML = this.content;
|
|
17796
17844
|
if (this.isExternal) target.appendChild(cont);
|
|
17797
17845
|
else target.parentNode.insertBefore(cont, target.nextSibling);
|
|
17798
17846
|
this.cont = cont;
|
|
17799
|
-
this.emitter.on(["initialized", "after-filtering"], () => this.toggle());
|
|
17800
|
-
/** @inherited */
|
|
17801
|
-
this.initialized = true;
|
|
17802
17847
|
}
|
|
17803
17848
|
/**
|
|
17804
17849
|
* Toggle no results message
|
|
@@ -17841,9 +17886,12 @@
|
|
|
17841
17886
|
/** Remove feature */
|
|
17842
17887
|
destroy() {
|
|
17843
17888
|
if (!this.initialized) return;
|
|
17844
|
-
removeElm(this.cont);
|
|
17889
|
+
if (this.cont && this.cont.parentNode) removeElm(this.cont);
|
|
17845
17890
|
this.cont = null;
|
|
17846
|
-
|
|
17891
|
+
if (this.boundToggle) {
|
|
17892
|
+
this.emitter.off(TOGGLE_EVENTS, this.boundToggle);
|
|
17893
|
+
this.boundToggle = null;
|
|
17894
|
+
}
|
|
17847
17895
|
this.initialized = false;
|
|
17848
17896
|
}
|
|
17849
17897
|
};
|
|
@@ -18737,7 +18785,7 @@
|
|
|
18737
18785
|
* Current version
|
|
18738
18786
|
* @type {String}
|
|
18739
18787
|
*/
|
|
18740
|
-
this.version = "0.7.
|
|
18788
|
+
this.version = "0.7.14";
|
|
18741
18789
|
/**
|
|
18742
18790
|
* Current year
|
|
18743
18791
|
* @type {Number}
|
|
@@ -19440,10 +19488,21 @@
|
|
|
19440
19488
|
this.instantiateFeatures(FEATURES);
|
|
19441
19489
|
}
|
|
19442
19490
|
/**
|
|
19491
|
+
* Throws when the table is not attached to the document.
|
|
19492
|
+
* @private
|
|
19493
|
+
*/
|
|
19494
|
+
assertTableAttached() {
|
|
19495
|
+
const rootEl = doc.documentElement;
|
|
19496
|
+
if (!rootEl || !rootEl.contains(this.dom())) throw new Error(`Could not initialise TableFilter: the HTML table
|
|
19497
|
+
is not attached to the document. Append it to the DOM before
|
|
19498
|
+
init().`);
|
|
19499
|
+
}
|
|
19500
|
+
/**
|
|
19443
19501
|
* Initialise features and layout
|
|
19444
19502
|
*/
|
|
19445
19503
|
init() {
|
|
19446
19504
|
if (this.initialized) return;
|
|
19505
|
+
this.assertTableAttached();
|
|
19447
19506
|
this.import(this.stylesheetId, this.getStylesheetPath(), null, "link");
|
|
19448
19507
|
let Mod = this.Mod;
|
|
19449
19508
|
let inpclass;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tablefilter",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.14",
|
|
4
4
|
"description": "A Javascript library making HTML tables filterable and a bit more",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -31,11 +31,11 @@
|
|
|
31
31
|
"scripts": {
|
|
32
32
|
"lint": "eslint src/**/*.js test/*.js test/playwright/*.js *.js",
|
|
33
33
|
"lint:css-tokens": "node scripts/check-css-tokens.js",
|
|
34
|
-
"dev": "node scripts/with-legacy-openssl.js webpack --
|
|
35
|
-
"build": "node scripts/with-legacy-openssl.js webpack --
|
|
34
|
+
"dev": "node scripts/with-legacy-openssl.js webpack --color --config webpack.dev.config.js",
|
|
35
|
+
"build": "node scripts/with-legacy-openssl.js webpack --color --config webpack.config.js",
|
|
36
36
|
"build:css": "stylus -c static/style/tablefilter.styl -o dist/tablefilter/style && stylus -c static/style/extensions -o dist/tablefilter/style && stylus -c static/style/themes/default -o dist/tablefilter/style/themes/default && stylus -c static/style/themes/mytheme -o dist/tablefilter/style/themes/mytheme && stylus -c static/style/themes/skyblue -o dist/tablefilter/style/themes/skyblue && stylus -c static/style/themes/transparent -o dist/tablefilter/style/themes/transparent",
|
|
37
37
|
"build:demos": "grunt build-demos",
|
|
38
|
-
"build:test": "node scripts/with-legacy-openssl.js webpack --
|
|
38
|
+
"build:test": "node scripts/with-legacy-openssl.js webpack --color --config webpack.test.config.js",
|
|
39
39
|
"build:vite": "vite build",
|
|
40
40
|
"serve:vite": "npm run build:vite && vite --port 8080 --strictPort",
|
|
41
41
|
"server": "node scripts/with-legacy-openssl.js webpack-dev-server --colors --hot --config ./webpack.dev.config.js",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"babel-eslint": "10.1.0",
|
|
61
61
|
"babel-loader": "^8.0.2",
|
|
62
62
|
"babel-preset-env": "1.7.0",
|
|
63
|
-
"clean-webpack-plugin": "^
|
|
63
|
+
"clean-webpack-plugin": "^4.0.0",
|
|
64
64
|
"codecov": "3.7.1",
|
|
65
65
|
"diacritics": "1.3.0",
|
|
66
66
|
"esdoc": "1.1.0",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"grunt": "^1.0.1",
|
|
70
70
|
"grunt-cli": "1.5.0",
|
|
71
71
|
"grunt-contrib-clean": "^2.0.0",
|
|
72
|
-
"grunt-contrib-connect": "^
|
|
72
|
+
"grunt-contrib-connect": "^5.0.1",
|
|
73
73
|
"grunt-contrib-copy": "^1.0.0",
|
|
74
74
|
"grunt-contrib-watch": "^1.0.0",
|
|
75
75
|
"grunt-qunit-istanbul": "1.1.0",
|
|
@@ -78,12 +78,12 @@
|
|
|
78
78
|
"isparta-loader": "2.0.0",
|
|
79
79
|
"script-loader": "^0.7.0",
|
|
80
80
|
"string-replace-webpack-plugin": "^0.1.3",
|
|
81
|
-
"stylus": "^0.
|
|
81
|
+
"stylus": "^0.55.0",
|
|
82
82
|
"sugar-date": "2.0.6",
|
|
83
83
|
"uglifyjs-webpack-plugin": "2.2.0",
|
|
84
84
|
"vite": "8.3.4",
|
|
85
85
|
"webpack": "^4.38.0",
|
|
86
|
-
"webpack-cli": "^
|
|
86
|
+
"webpack-cli": "^4.10.0",
|
|
87
87
|
"webpack-dev-server": "^4.15.2"
|
|
88
88
|
},
|
|
89
89
|
"bugs": {
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `<tf-no-results>` custom element: polite no-results announcement.
|
|
3
|
+
*
|
|
4
|
+
* An open shadow root exposes the `message-slot` and `message` parts.
|
|
5
|
+
* Consumer markup (`no_results_message.content`,
|
|
6
|
+
* ROADMAP/content-projection-parity.md) renders through the default slot;
|
|
7
|
+
* the `text` attribute is the plain-text fallback rendered as text into
|
|
8
|
+
* `message`, which hides while slotted content is present.
|
|
9
|
+
*
|
|
10
|
+
* `connectedCallback()` applies the shared live-region contract to the host.
|
|
11
|
+
* The bridge sanitises configured markup with `sanitizeHtml()` before
|
|
12
|
+
* projecting it (P7, ROADMAP/content-projection-parity.md). The configurable
|
|
13
|
+
* message class (`no_results_message.css_class`), external containers
|
|
14
|
+
* (`custom_container`/`custom_container_id`) and show/hide callbacks stay in
|
|
15
|
+
* the bridge (#919). The look comes from the stylesheet and themes.
|
|
16
|
+
*
|
|
17
|
+
* Importing this module registers the element. Consumers load this module
|
|
18
|
+
* directly; #965 tracks the legacy webpack bundle.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import {applyLiveRegion} from './attributes.js';
|
|
22
|
+
|
|
23
|
+
const TEMPLATE = document.createElement('template');
|
|
24
|
+
TEMPLATE.innerHTML = `
|
|
25
|
+
<slot part="message-slot"></slot>
|
|
26
|
+
<span part="message"></span>
|
|
27
|
+
`;
|
|
28
|
+
|
|
29
|
+
export class TfNoResultsElement extends HTMLElement {
|
|
30
|
+
constructor() {
|
|
31
|
+
super();
|
|
32
|
+
this.attachShadow({ mode: 'open' });
|
|
33
|
+
this.shadowRoot.appendChild(TEMPLATE.content.cloneNode(true));
|
|
34
|
+
this._messageSlot =
|
|
35
|
+
this.shadowRoot.querySelector('[part="message-slot"]');
|
|
36
|
+
this._messageEl = this.shadowRoot.querySelector('[part="message"]');
|
|
37
|
+
|
|
38
|
+
this._messageSlot.addEventListener(
|
|
39
|
+
'slotchange', () => this._syncLayout());
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
static get observedAttributes() {
|
|
43
|
+
return ['text'];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
connectedCallback() {
|
|
47
|
+
applyLiveRegion(this);
|
|
48
|
+
this._update();
|
|
49
|
+
this._syncLayout();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
attributeChangedCallback() {
|
|
53
|
+
this._update();
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Set the fallback message text. Values are coerced to strings; 0
|
|
58
|
+
* renders as '0'.
|
|
59
|
+
* @param {String} text Message text
|
|
60
|
+
*/
|
|
61
|
+
setText(text) {
|
|
62
|
+
this.setAttribute('text', text == null ? '' : String(text));
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Render the `text` attribute as text into the `message` part.
|
|
67
|
+
*/
|
|
68
|
+
_update() {
|
|
69
|
+
if (this._messageEl) {
|
|
70
|
+
this._messageEl.textContent = this.getAttribute('text') || '';
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Hide the message part while the default slot carries an element or a
|
|
76
|
+
* non-whitespace text node.
|
|
77
|
+
*/
|
|
78
|
+
_syncLayout() {
|
|
79
|
+
if (!this._messageEl) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
this._messageEl.hidden = this._messageSlot
|
|
83
|
+
.assignedNodes({ flatten: true })
|
|
84
|
+
.some((node) => node.nodeType === 1 ||
|
|
85
|
+
(node.nodeType === 3 && node.textContent.trim() !== ''));
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// Register once: loading this module twice, or on a page that already
|
|
90
|
+
// defined the element, keeps the existing definition.
|
|
91
|
+
if (typeof customElements !== 'undefined' &&
|
|
92
|
+
!customElements.get('tf-no-results')) {
|
|
93
|
+
customElements.define('tf-no-results', TfNoResultsElement);
|
|
94
|
+
}
|
package/src/modules/noResults.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import {Feature} from '../feature';
|
|
2
2
|
import {createElm, elm, removeElm} from '../dom';
|
|
3
|
-
import {
|
|
3
|
+
import {EMPTY_FN} from '../types';
|
|
4
4
|
import {NONE} from '../const';
|
|
5
5
|
import {defaultsStr, defaultsFn} from '../settings';
|
|
6
|
+
import {sanitizeHtml} from '../sanitize';
|
|
7
|
+
|
|
8
|
+
const TOGGLE_EVENTS = ['initialized', 'after-filtering'];
|
|
6
9
|
|
|
7
10
|
/**
|
|
8
11
|
* UI when filtering yields no matches
|
|
@@ -32,7 +35,9 @@ export class NoResults extends Feature {
|
|
|
32
35
|
* Custom container DOM element
|
|
33
36
|
* @type {DOMElement}
|
|
34
37
|
*/
|
|
35
|
-
this.customContainer =
|
|
38
|
+
this.customContainer = f.custom_container &&
|
|
39
|
+
typeof f.custom_container.appendChild === 'function' ?
|
|
40
|
+
f.custom_container : null;
|
|
36
41
|
|
|
37
42
|
/**
|
|
38
43
|
* ID of custom container element
|
|
@@ -41,12 +46,12 @@ export class NoResults extends Feature {
|
|
|
41
46
|
this.customContainerId = defaultsStr(f.custom_container_id, null);
|
|
42
47
|
|
|
43
48
|
/**
|
|
44
|
-
*
|
|
49
|
+
* True when a container element is present or a container id is set
|
|
45
50
|
* @type {Boolean}
|
|
46
51
|
* @private
|
|
47
52
|
*/
|
|
48
|
-
this.isExternal =
|
|
49
|
-
|
|
53
|
+
this.isExternal = Boolean(this.customContainer) ||
|
|
54
|
+
Boolean(this.customContainerId);
|
|
50
55
|
|
|
51
56
|
/**
|
|
52
57
|
* Css class assigned to container element
|
|
@@ -83,6 +88,13 @@ export class NoResults extends Feature {
|
|
|
83
88
|
* @type {Function}
|
|
84
89
|
*/
|
|
85
90
|
this.onAfterHide = defaultsFn(f.on_after_hide_msg, EMPTY_FN);
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Subscribed toggle handler
|
|
94
|
+
* @type {Function|null}
|
|
95
|
+
* @private
|
|
96
|
+
*/
|
|
97
|
+
this.boundToggle = null;
|
|
86
98
|
}
|
|
87
99
|
|
|
88
100
|
/**
|
|
@@ -92,11 +104,66 @@ export class NoResults extends Feature {
|
|
|
92
104
|
if (this.initialized) {
|
|
93
105
|
return;
|
|
94
106
|
}
|
|
95
|
-
let
|
|
96
|
-
|
|
97
|
-
|
|
107
|
+
let targetEl = this.isExternal ?
|
|
108
|
+
this.customContainer || elm(this.customContainerId) : null;
|
|
109
|
+
|
|
110
|
+
// TODO(#965): remove once the legacy webpack pipeline is retired.
|
|
111
|
+
if (this.canUseCE(targetEl)) {
|
|
112
|
+
this.initCE(targetEl);
|
|
113
|
+
} else {
|
|
114
|
+
this.initLegacy(targetEl);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
this.boundToggle = () => this.toggle();
|
|
118
|
+
this.emitter.on(TOGGLE_EVENTS, this.boundToggle);
|
|
119
|
+
|
|
120
|
+
/** @inherited */
|
|
121
|
+
this.initialized = true;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Whether the feature renders through `<tf-no-results>`.
|
|
126
|
+
* @param {DOMElement} targetEl Resolved external container, if any
|
|
127
|
+
* @returns {Boolean} True when the registered element exposes `setText`
|
|
128
|
+
* and no external container is configured, or the container resolves
|
|
129
|
+
* @private
|
|
130
|
+
*/
|
|
131
|
+
canUseCE(targetEl) {
|
|
132
|
+
const NoResultsElement = typeof customElements === 'undefined' ?
|
|
133
|
+
null : customElements.get('tf-no-results');
|
|
134
|
+
return Boolean(NoResultsElement) &&
|
|
135
|
+
typeof NoResultsElement.prototype.setText === 'function' &&
|
|
136
|
+
(!this.isExternal || Boolean(targetEl &&
|
|
137
|
+
typeof targetEl.appendChild === 'function'));
|
|
138
|
+
}
|
|
98
139
|
|
|
99
|
-
|
|
140
|
+
/**
|
|
141
|
+
* Initialize using the <tf-no-results> custom element
|
|
142
|
+
* @param {DOMElement} targetEl External container element
|
|
143
|
+
* @private
|
|
144
|
+
*/
|
|
145
|
+
initCE(targetEl) {
|
|
146
|
+
const host = document.createElement('tf-no-results');
|
|
147
|
+
host.className = this.cssClass;
|
|
148
|
+
host.setText('');
|
|
149
|
+
host.innerHTML = sanitizeHtml(this.content);
|
|
150
|
+
|
|
151
|
+
if (this.isExternal) {
|
|
152
|
+
targetEl.appendChild(host);
|
|
153
|
+
} else {
|
|
154
|
+
const dom = this.tf.dom();
|
|
155
|
+
dom.parentNode.insertBefore(host, dom.nextSibling);
|
|
156
|
+
}
|
|
157
|
+
this.cont = host;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Initialize using the legacy div container
|
|
162
|
+
* @param {DOMElement} targetEl External container element
|
|
163
|
+
* @private
|
|
164
|
+
*/
|
|
165
|
+
initLegacy(targetEl) {
|
|
166
|
+
let target = targetEl || this.tf.dom();
|
|
100
167
|
let cont = createElm('div');
|
|
101
168
|
cont.className = this.cssClass;
|
|
102
169
|
cont.innerHTML = this.content;
|
|
@@ -108,15 +175,6 @@ export class NoResults extends Feature {
|
|
|
108
175
|
}
|
|
109
176
|
|
|
110
177
|
this.cont = cont;
|
|
111
|
-
|
|
112
|
-
// subscribe to after-filtering event
|
|
113
|
-
this.emitter.on(
|
|
114
|
-
['initialized', 'after-filtering'],
|
|
115
|
-
() => this.toggle()
|
|
116
|
-
);
|
|
117
|
-
|
|
118
|
-
/** @inherited */
|
|
119
|
-
this.initialized = true;
|
|
120
178
|
}
|
|
121
179
|
|
|
122
180
|
/**
|
|
@@ -183,10 +241,14 @@ export class NoResults extends Feature {
|
|
|
183
241
|
if (!this.initialized) {
|
|
184
242
|
return;
|
|
185
243
|
}
|
|
186
|
-
|
|
244
|
+
if (this.cont && this.cont.parentNode) {
|
|
245
|
+
removeElm(this.cont);
|
|
246
|
+
}
|
|
187
247
|
this.cont = null;
|
|
188
|
-
|
|
189
|
-
|
|
248
|
+
if (this.boundToggle) {
|
|
249
|
+
this.emitter.off(TOGGLE_EVENTS, this.boundToggle);
|
|
250
|
+
this.boundToggle = null;
|
|
251
|
+
}
|
|
190
252
|
|
|
191
253
|
this.initialized = false;
|
|
192
254
|
}
|
package/src/tablefilter.js
CHANGED
|
@@ -937,6 +937,19 @@ export class TableFilter {
|
|
|
937
937
|
this.instantiateFeatures(FEATURES);
|
|
938
938
|
}
|
|
939
939
|
|
|
940
|
+
/**
|
|
941
|
+
* Throws when the table is not attached to the document.
|
|
942
|
+
* @private
|
|
943
|
+
*/
|
|
944
|
+
assertTableAttached() {
|
|
945
|
+
const rootEl = doc.documentElement;
|
|
946
|
+
if (!rootEl || !rootEl.contains(this.dom())) {
|
|
947
|
+
throw new Error(`Could not initialise TableFilter: the HTML table
|
|
948
|
+
is not attached to the document. Append it to the DOM before
|
|
949
|
+
init().`);
|
|
950
|
+
}
|
|
951
|
+
}
|
|
952
|
+
|
|
940
953
|
/**
|
|
941
954
|
* Initialise features and layout
|
|
942
955
|
*/
|
|
@@ -945,6 +958,8 @@ export class TableFilter {
|
|
|
945
958
|
return;
|
|
946
959
|
}
|
|
947
960
|
|
|
961
|
+
this.assertTableAttached();
|
|
962
|
+
|
|
948
963
|
// import main stylesheet
|
|
949
964
|
this.import(this.stylesheetId, this.getStylesheetPath(), null, 'link');
|
|
950
965
|
|