Skip to content

Commit 3a2a7a0

Browse files
authored
Don't exclude enumerable properties from Object (#46)
Fixes #45
1 parent 6278502 commit 3a2a7a0

File tree

5 files changed

+27
-10
lines changed

5 files changed

+27
-10
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## master
44

5+
* [#45](https://github.com/clojure-emacs/clj-suitable/issues/45): don't exclude enumerable properties from `Object`.
6+
57
## 0.6.1 (2023-11-07)
68

79
- [#44](https://github.com/clojure-emacs/clj-suitable/pull/44): More robust completion for referred keywords. If a given namespace is

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ clean:
1313
lein with-profile -user clean
1414

1515
test: clean
16-
clojure -A:test:$(VERSION) -d src/test
16+
clojure -M:test:test-runner:$(VERSION)
1717

1818
kondo:
1919
clojure -M:dev-figwheel:fig-repl:dev-shadow:test:kondo

deps.edn

+6-6
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@
4444
:main-opts ["-m" "figwheel.main" "-b" "fig"]
4545
:extra-deps {com.bhauman/figwheel-main {:mvn/version "0.2.18"}}}
4646

47-
;; tests
4847
:test {:extra-paths ["src/test" "resources"]
49-
:extra-deps {com.cognitect/test-runner {:git/url "https://github.com/cognitect-labs/test-runner.git"
50-
:sha "209b64504cb3bd3b99ecfec7937b358a879f55c1"}
51-
cider/cider-nrepl {:mvn/version "0.32.0"}
48+
:extra-deps {cider/cider-nrepl {:mvn/version "0.32.0"}
5249
cider/piggieback {:mvn/version "0.5.3"}}
53-
:jvm-opts ["-Dclojure.main.report=stderr"]
54-
:main-opts ["-m" "cognitect.test-runner" "-d" "src/test"]}
50+
:jvm-opts ["-Dclojure.main.report=stderr"]}
51+
52+
:test-runner {:extra-deps {com.cognitect/test-runner {:git/url "https://github.com/cognitect-labs/test-runner.git"
53+
:sha "209b64504cb3bd3b99ecfec7937b358a879f55c1"}}
54+
:main-opts ["-m" "cognitect.test-runner" "-d" "src/test"]}
5555

5656
;; build a jar, https://juxt.pro/blog/posts/pack-maven.html
5757
:pack {:extra-deps {pack/pack.alpha {:git/url "https://github.com/juxt/pack.alpha.git"

src/main/suitable/js_introspection.cljs

+4-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@
2828
(for [[i {:keys [_obj props]}] (map-indexed vector (properties-by-prototype js-obj))
2929
key (js-keys props)
3030
:when (and (not (get @seen key))
31-
(not (oget (oget props key) "enumerable"))
31+
(if (or (= "[object String]" (js/Object.prototype.toString.call js-obj))
32+
(js/Array.isArray js-obj))
33+
(not (oget (oget props key) "enumerable"))
34+
true)
3235
(or (empty? prefix)
3336
(starts-with? key prefix)))]
3437
(let [prop (oget props key)]

src/test/suitable/complete_for_nrepl_test.clj

+14-2
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@
105105
(is (= [{:ns "js/Object", :candidate ".keys" :type "function"}] candidates)
106106
(pr-str response))))
107107

108-
(testing "make sure that enumerable items are filtered out"
108+
(testing "enumerable items are filtered out"
109109
(are [context candidates] (= candidates
110110
(let [response (message {:op "complete"
111111
:ns "cljs.user"
@@ -116,7 +116,19 @@
116116
[{:candidate ".-length", :ns "(js/String \"abc\")", :type "var"}]
117117

118118
"(-> (js/String \"abc\") __prefix__)"
119-
[{:candidate ".-length", :ns "(-> (js/String \"abc\"))", :type "var"}]))))
119+
[{:candidate ".-length", :ns "(-> (js/String \"abc\"))", :type "var"}]
120+
121+
"(__prefix__ #js [1 2 3])"
122+
[]
123+
124+
"(__prefix__ (array 1 2 3))"
125+
[{:candidate ".-length", :ns "(array 1 2 3)", :type "var"}]
126+
127+
"(__prefix__ (js/Array. 1 2 3))"
128+
[{:candidate ".-length", :ns "(js/Array. 1 2 3)", :type "var"}]
129+
130+
"(__prefix__ (js/Set. (js/Array. 1 2 3)))"
131+
[{:candidate ".-size", :ns "(js/Set. (js/Array. 1 2 3))", :type "var"}]))))
120132

121133
(deftest node-env?
122134
(is (false? (sut/node-env? nil)))

0 commit comments

Comments
 (0)