Skip to content

Commit

Permalink
Fix linting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
DrRataplan committed Feb 19, 2025
1 parent d0d9a69 commit 4aff200
Show file tree
Hide file tree
Showing 7 changed files with 389 additions and 204 deletions.
6 changes: 3 additions & 3 deletions src/binding/Binding.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {DependencyTracker} from "../DependencyTracker.js";
import { DependencyTracker } from '../DependencyTracker.js';

/**
* Common base class for all bindings allowing to register them with DependencyTracker
Expand All @@ -10,9 +10,9 @@ export class Binding {
this.bindingType = type;
}

update(){
update() {
console.log(`updating Binding ${this.xpath}`, this);
DependencyTracker.getInstance().pendingUpdates.delete(this);
// console.log('pendingUpdates after deletion', Array.from(DependencyTracker.getInstance().pendingUpdates));
}
}
}
69 changes: 42 additions & 27 deletions src/binding/ControlBinding.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,50 @@ import { Binding } from './Binding.js';
import { detectTemplateExpressions } from './detectTemplateStrings.js';

export class ControlBinding extends Binding {
constructor(control) {
super(control.getModelItem().path, 'control');
/**
* @type {ModelItem}
*/
this.modelItem = control.getModelItem();
/**
* @type {ForeElementMixin}
*/
this.control = control;
constructor(control) {
super(control.getModelItem().path, 'control');
/**
* @type {ModelItem}
*/
this.modelItem = control.getModelItem();
/**
* @type {ForeElementMixin}
*/
this.control = control;

// TODO: only for non-default directly
detectTemplateExpressions(this.control);
// TODO: only for non-default directly
detectTemplateExpressions(this.control);

// The control depends on some facets of the bound node / model item
DependencyTracker.getInstance().registerBinding(this.modelItem.path, this);
DependencyTracker.getInstance().registerBinding(`${this.modelItem.path}:readonly`, this);
DependencyTracker.getInstance().registerBinding(`${this.modelItem.path}:relevant`, this);
DependencyTracker.getInstance().registerBinding(`${this.modelItem.path}:required`, this);
DependencyTracker.getInstance().registerBinding(`${this.modelItem.path}:constraint`, this);
}
// The control depends on some facets of the bound node / model item
DependencyTracker.getInstance().registerBinding(
this.modelItem.path,
this,
);
DependencyTracker.getInstance().registerBinding(
`${this.modelItem.path}:readonly`,
this,
);
DependencyTracker.getInstance().registerBinding(
`${this.modelItem.path}:relevant`,
this,
);
DependencyTracker.getInstance().registerBinding(
`${this.modelItem.path}:required`,
this,
);
DependencyTracker.getInstance().registerBinding(
`${this.modelItem.path}:constraint`,
this,
);
}

update() {
super.update();
this.refresh();
}
update() {
super.update();
this.refresh();
}

refresh() {
// console.log('control refreshing')
this.control.refresh();
}
refresh() {
// console.log('control refreshing')
this.control.refresh();
}
}
27 changes: 17 additions & 10 deletions src/binding/FacetBinding.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
// FacetBinding.js
import {DependencyTracker} from "../DependencyTracker";
import {DependencyNotifyingDomFacade} from "../DependencyNotifyingDomFacade";
import {XPathUtil} from "../xpath-util";
import {evaluateXPath, evaluateXPathToBoolean, evaluateXPathToString} from "../xpath-evaluation";
import getInScopeContext from "../getInScopeContext";
import {Binding} from "./Binding.js";
import { DependencyTracker } from '../DependencyTracker';
import { DependencyNotifyingDomFacade } from '../DependencyNotifyingDomFacade';
import { XPathUtil } from '../xpath-util';
import {
evaluateXPath,
evaluateXPathToBoolean,
evaluateXPathToString,
} from '../xpath-evaluation';
import getInScopeContext from '../getInScopeContext';
import { Binding } from './Binding.js';

/**
* represents a single facet of a NodeBinding.
Expand Down Expand Up @@ -63,8 +67,8 @@ export class FacetBinding extends Binding {
}

compute() {
const modelItem = this.modelItem;
const facetName = this.facetName;
const { modelItem } = this;
const { facetName } = this;
const expr = modelItem.bind[facetName];
const fore = modelItem.bind.getOwnerForm();

Expand All @@ -75,7 +79,11 @@ export class FacetBinding extends Binding {
} else if (facetName !== 'constraint' && facetName !== 'type') {
// ### re-compute the Boolean value of all facets expect 'constraint' and 'type' which are handled in revalidate()
if (this.expression) {
const compute = evaluateXPathToBoolean(expr, modelItem.node, fore);
const compute = evaluateXPathToBoolean(
expr,
modelItem.node,
fore,
);
modelItem[facetName] = compute;
console.log(
`recalculating path ${this.xpath} - Expr:'${this.expression}' computed`,
Expand All @@ -84,5 +92,4 @@ export class FacetBinding extends Binding {
}
}
}

}
Loading

0 comments on commit 4aff200

Please sign in to comment.