singult icon indicating copy to clipboard operation
singult copied to clipboard

Merge should remove stale attributes and inline styles

Open lynaghk opened this issue 12 years ago • 3 comments

Currently merge only projects attributes from hiccup to the DOM---that'll overwrite any existing attributes, but it doesn't clear out attributes that aren't in the Hiccup representation.

lynaghk avatar Jul 03 '12 17:07 lynaghk

I'm actually relying on this not happening. For example, a "selected" component (via class name) will stay selected even after some filter is applied. I can see how removing would be closer to the idea of merging though. I guess the trade-off is keeping an extra state variable around that tracks the state of any elements of interest.

jblomo avatar Nov 26 '12 05:11 jblomo

We're in the same boat on several applications. Occasionally it is nice to go "out of band" to twiddle an individual class on or off via a direct element reference rather than go through Singult to walk the entire DOM. This is especially useful with performance on mobile devices. However, the contract of Singult is "the DOM should look like this Hiccup", so I'm of the mind to consider it a bug. That said, development of Singult is on hold at the moment while I look into more fruitful CLJS <-> DOM manipulation architectures, so don't worry about the behavior changing anytime soon.

lynaghk avatar Nov 28 '12 04:11 lynaghk

For anyone reading this and disparing for a way to remove attributes with merge, setting an attribute to nil will cause singult to remove it from the dom.

e.g. (using c2's bind)

(bind! [:input :disabled (if @enabled nil true)])

will result in the disabled attribute being added and removed appropriate when the 'enabled' atom changes.

sfnelson avatar Feb 08 '13 02:02 sfnelson