UNPKG

1.26 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3var SetTreeVisibilityVisitor = /** @class */ (function () {
4 function SetTreeVisibilityVisitor(visible) {
5 this.visible = visible;
6 }
7 SetTreeVisibilityVisitor.prototype.run = function (root) {
8 this.visit(root);
9 };
10 SetTreeVisibilityVisitor.prototype.visitArray = function (nodes) {
11 if (!nodes) {
12 return nodes;
13 }
14 var cnt = nodes.length;
15 var i;
16 for (i = 0; i < cnt; i++) {
17 this.visit(nodes[i]);
18 }
19 return nodes;
20 };
21 SetTreeVisibilityVisitor.prototype.visit = function (node) {
22 if (!node) {
23 return node;
24 }
25 if (node.constructor === Array) {
26 return this.visitArray(node);
27 }
28 if (!node.blocksVisibility || node.blocksVisibility()) {
29 return node;
30 }
31 if (this.visible) {
32 node.ensureVisibility();
33 }
34 else {
35 node.ensureInvisibility();
36 }
37 node.accept(this);
38 return node;
39 };
40 return SetTreeVisibilityVisitor;
41}());
42exports.default = SetTreeVisibilityVisitor;
43//# sourceMappingURL=set-tree-visibility-visitor.js.map
\No newline at end of file