Comments (4)
I encountered the same problem when implementing todo-mvc application (https://github.com/ITEdge/todo-mvc-pedestal), but i think it's actually a domina library bug, not the pedestal one. As a workaround i recommend wrappoing every dynamic html content div in a appropriate wrapper outer html tag and place listeners to this outer tag, this is for example how i solved it in todo-mvc:
<label>
<span field="content:text">Create a TodoMVC template</span>
</label>
A attached a double-click handler to the label field and it's working, but a template under would experience the problem mentioned above:
<label field="content:text">Create a TodoMVC template</label>
from pedestal.
The offending code in domina is here:
https://github.com/levand/domina/blob/master/src/cljs/domina.cljs#L371-#L397
The problem is here:
(doseq [node (nodes content)]
(events/removeAll node)
(set! (. node -innerHTML) value))
It's removing all events for all the nodes.
You can grab all the event listeners on an object if you use domina.events/get-listeners
You have to supply the node, event type, so I'd thinking something like:
(let [evt-listeners (map #(domina.events/get-listeners node %)
[:click :dblclick :keydown ...etc] )
;; Call to domina/set-html!
;; Put the evt-listeners back on the node
from pedestal.
(defn update-template [t m]
(doseq [[k v] t {:keys [id type attr-name]} v]
(case type
:attr (cond (and (contains? m k) (nil? (get m k)))
(d/remove-attr! (d/by-id id) attr-name)
(contains? m k)
(d/set-attrs! (d/by-id id) {attr-name (get m k)}))
:content (when (contains? m k)
;; Save any previous event handlers, the call to set-html! wipes out previous event handlers
;; Have to use doall to force evaluation of the lazy seq. When the handlers are wiped, they
;; can lead to the functions getting garbage collected, this stops it by making sure a reference
;; remains
(let [handlers (doall (flatten
(map (fn [evt-type]
;; Save the listener function and its event type
(map (fn [x] {:fn (.-listener x) :type (.-type x)})
;; Get all the listeners given the event type
(de/get-listeners (d/by-id id) evt-type)))
;; This is all the possible event types
de/builtin-events)))]
;; Reset the template's html
(d/set-html! (d/by-id id) (get m k))
;; Put the event handlers back
(when (seq handlers)
(doseq [handler handlers]
(de/listen! (d/by-id id) (:type handler)
(:fn handler)))))
)
nil)))
Make sure to include a require for domina.events
[domina.events :as de]
This works, and the tests pass.
from pedestal.
It’s with a heavy ❤️ that we’ve decided to put pedestal-app on hold for now.
You'll find a replica of this issue at pedestal/pedestal-app#16
from pedestal.
Related Issues (20)
- Netty example
- Upgrading to SLF4J 2.x
- It should be easier to start a connector listening on multiple ports
- Standardize support for web sockets HOT 1
- Remove support for Immutant HOT 4
- There is no test for the ClojureVarServlet HOT 1
- There are no tests for websocket support HOT 2
- Pedestal is not AOT-friendly HOT 1
- Security vulnerabilities related to Jetty 9.4.51 HOT 3
- proper support to VirtualThreads on pedestal.log HOT 1
- CVEs in Jetty 9.5.52 allow for DDoS attacks via HTTP/2 HOT 1
- Transit reader broken for some input stream implementations HOT 2
- Setup a stable performance testing environment
- Add a template for use with deps-new
- Seperate API documentation for each major release (0.6, 0.7, etc.) HOT 2
- Unable to access the application when running with Docker and io.pedestal/pedestal.service "0.6.1" HOT 2
- Support transformation of logging events at output HOT 1
- path-params-decoder interceptor should be idempotent HOT 1
- Re-enable nvd-clojure vulnerability checks once nvd-clojure updated to use DependencyCheck 9.x HOT 1
- Add configuration for linting using clj-kondo HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pedestal.