An expression is a JavaScript construct that evaluates to a value. In wrec, expressions can supply element text, attribute values, CSS property values, and computed properties. section 8.3
When a property used by an expression changes, wrec recomputes the expression and updates the DOM. Duplicate expressions in one component are recomputed only once. section 8.3
Reactive rectangle
A component can bind sliders to this.height and this.width, display this.width * this.height as area, and use this.color, this.height + "px", and this.width + "px" in CSS. Adding :input updates a property while a slider is dragged rather than after its change event. section 8.3
Listing 8.2 expressions-demo.ts class definition
import { css, html, Wrec } from "wrec";
class ExpressionsDemo extends Wrec {
static properties = {
color: { type: String, value: "red" },
height: { type: Number, value: 100 },
width: { type: Number, value: 200 },
max: { type: Number, value: 800 },
};
static css = css`
#1
`;
static html = html`
#2
`;
}
ExpressionsDemo.define("expressions-demo");
Browse the component definition behind the expression examples. section 8.3













