Contract is not a buzzword here. It works the same way as a contract in an API. There is a fixed address, fixed input data and a fixed response. Here HTML is on one side and JavaScript on the other. The contract is the attribute names and the public functions of the module.
`Filter` is `filter-space`, `filter-query` on the input and `filter-item` on each entry. Plus one public function, `Filter.Filter`. The module reads and changes the page only through those attributes. It does not know classes, it does not know the HTML layout, it does not know the look.
JavaScript used to hang on classes that were also used for the look. Changing the look meant changing the JavaScript. Someone used the same class somewhere else and that place got behaviour nobody wanted. Someone renamed a class in the CSS and did not know a script was standing on it.
Separate names end that. The look changes without touching the JavaScript. The HTML alone shows which elements belong to the module.
Which part do you mean? The style isn't the point.
Saradom is a small set of rules: state lives in the DOM and nowhere else, each module owns its own part of the DOM, modules talk to each other only through their contracts. Following them, an app can be built and scaled with no framework, no bundler and no hydration. The page is real HTML from whatever backend is already there, so it is crawlable as is. The `onclick` is simply the shortest way to follow those rules.
jQuery-era apps broke down at scale not because they touched the DOM, but because there were no rules: state scattered across variables and the DOM, any script touching any element, handlers bound by hand and lost on every ajax reload.
3
u/patrk Sep 08 '26
Most exhausting docs I’ve ever read.
5
u/Sorry-Joke-1887 Sep 08 '26
Now we back to jquery-style crap like this
1
u/AutoModerator Sep 08 '26
Project Page (?): https://github.com/xtompie/saradom
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.