mirror of https://github.com/status-im/pluto.git
[Fixes #68] Ensure no unknown symbols are used
This commit is contained in:
parent
5ac25d2d46
commit
808ac1616d
|
@ -1,5 +1,6 @@
|
|||
(ns pluto.reader.views
|
||||
(:require [clojure.spec.alpha :as spec]
|
||||
(:require [clojure.set :as set]
|
||||
[clojure.spec.alpha :as spec]
|
||||
#?(:cljs [reagent.core :as reagent])
|
||||
[pluto.reader.blocks :as blocks]
|
||||
[pluto.reader.errors :as errors]
|
||||
|
@ -125,9 +126,8 @@
|
|||
(defn unresolved-properties [acc o]
|
||||
(cond
|
||||
(symbol? o) (conj acc o)
|
||||
(vector? o)
|
||||
(let [[_ _ & children] o]
|
||||
(reduce #(apply conj %1 (unresolved-properties acc %2)) acc children))
|
||||
(map? o) (reduce #(apply conj %1 (unresolved-properties acc %2)) acc (vals o))
|
||||
(vector? o) (reduce #(apply conj %1 (unresolved-properties acc %2)) acc o)
|
||||
:else acc))
|
||||
|
||||
(defn event->fn [ctx ext event f]
|
||||
|
@ -152,6 +152,7 @@
|
|||
"Inject `properties` into the top level `let` block."
|
||||
;; TODO remove this dependency on specifics of let block
|
||||
[h properties]
|
||||
(println "Inject" properties)
|
||||
(if (vector? h)
|
||||
(let [[tag & properties-children] h
|
||||
[props children] (resolve-properties-children properties-children)
|
||||
|
@ -198,11 +199,13 @@
|
|||
(if errors
|
||||
{:errors errors}
|
||||
(let [d (parse ctx ext o data)
|
||||
props (reduce unresolved-properties #{} d)]
|
||||
;; TODO Properly introduce `bindings` at top parsing level, not in blocks
|
||||
props (set/difference (reduce unresolved-properties #{} d)
|
||||
(first (get-in data [1 :bindings])))]
|
||||
(errors/merge-errors
|
||||
d
|
||||
(concat errors (when (seq props)
|
||||
{:errors [(errors/error ::errors/unresolved-properties props)]}))))))
|
||||
(when (seq props)
|
||||
[(errors/error ::errors/unresolved-properties props)])))))
|
||||
(parse-hiccup-element ctx ext o))))
|
||||
|
||||
(defmethod types/resolve :view [ctx ext type value]
|
||||
|
|
Loading…
Reference in New Issue