phylotree 2.1.0 → 2.1.2

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.
@@ -388,8 +388,8 @@ export function modifySelection(
388
388
  }
389
389
  }
390
390
 
391
- if (this.selectionCallback && attr != "tag") {
392
- this.selectionCallback(this.getSelection());
391
+ if (this._selectionCallback && attr != "tag") {
392
+ this._selectionCallback(this.getSelection());
393
393
  }
394
394
 
395
395
  this.refresh();
@@ -403,7 +403,7 @@ export function modifySelection(
403
403
  * @returns {Array} An array of nodes that match the current selection.
404
404
  */
405
405
  export function getSelection() {
406
- return this.nodes.filter(d => {
406
+ return selectAllDescendants(this.phylotree.getRootNode(), true, true).filter(d => {
407
407
  return d[this.selection_attribute_name];
408
408
  });
409
409
  }
@@ -444,10 +444,10 @@ export function selectAllDescendants(node, terminal, internal) {
444
444
  * an array of nodes that make up the current selection.
445
445
  *
446
446
  * @param {Function} callback (Optional) The selection callback function.
447
- * @returns The current ``selectionCallback`` if getting, or the current ``this`` if setting.
447
+ * @returns The current ``_selectionCallback`` if getting, or the current ``this`` if setting.
448
448
  */
449
449
  export function selectionCallback(callback) {
450
- if (!callback) return this.selectionCallback;
451
- this.selectionCallback = callback;
450
+ if (!callback) return this._selectionCallback;
451
+ this._selectionCallback = callback;
452
452
  return this;
453
453
  }
@@ -18,6 +18,12 @@ export const css_classes = {
18
18
  node_text: "phylotree-node-text"
19
19
  };
20
20
 
21
+ export function initializeCssClasses(classes = {}) {
22
+ Object.keys(classes).forEach(key => {
23
+ css_classes[key] = classes[key]
24
+ })
25
+ }
26
+
21
27
  export function internalNames(attr) {
22
28
  if (!arguments.length) return this.options["internal-names"];
23
29
  this.options["internal-names"] = attr;
@@ -132,10 +138,10 @@ export var predefined_selecters = {
132
138
  * an array of nodes that make up the current selection.
133
139
  *
134
140
  * @param {Function} callback (Optional) The selection callback function.
135
- * @returns The current ``selectionCallback`` if getting, or the current ``this`` if setting.
141
+ * @returns The current ``_selectionCallback`` if getting, or the current ``this`` if setting.
136
142
  */
137
143
  export function selectionCallback(callback) {
138
- if (!callback) return this.selectionCallback;
139
- this.selectionCallback = callback;
144
+ if (!callback) return this._selectionCallback;
145
+ this._selectionCallback = callback;
140
146
  return this;
141
147
  }