|
1 | 1 | (ns cljs.proxy |
2 | | - (:refer-global :only [Proxy isNaN]) |
| 2 | + (:refer-global :only [isNaN Proxy Symbol]) |
3 | 3 | (:require [cljs.proxy.impl :refer [SimpleCache]])) |
4 | 4 |
|
5 | 5 | (defn- write-through [f] |
|
45 | 45 | (js* "var __ctor") |
46 | 46 | (let [cache-key-fn (write-through key-fn) |
47 | 47 | vec-handler #js {:get (fn [^cljs.core/IIndexed target prop receiver] |
48 | | - (if (identical? prop "length") |
| 48 | + (cond |
| 49 | + (identical? "length" prop) |
49 | 50 | (-count ^cljs.core/ICounted target) |
| 51 | + |
| 52 | + (identical? (. Symbol -iterator) prop) |
| 53 | + (.bind (unchecked-get target prop) target) |
| 54 | + |
| 55 | + (string? prop) |
50 | 56 | (let [n (js* "+~{}" prop)] |
51 | 57 | (when (and (number? n) |
52 | 58 | (not (isNaN n))) |
53 | 59 | (js/__ctor (-nth target n nil)))))) |
54 | 60 |
|
55 | 61 | :has (fn [^cljs.core/IAssociative target prop] |
56 | | - (if (identical? prop "length") |
57 | | - true |
| 62 | + (cond |
| 63 | + (identical? prop "length") true |
| 64 | + |
| 65 | + (identical? (. Symbol -iterator) prop) true |
| 66 | + |
| 67 | + (string? prop) |
58 | 68 | (let [n (js* "+~{}" prop)] |
59 | 69 | (and (number? n) |
60 | 70 | (not (isNaN n)) |
|
70 | 80 | :getOwnPropertyDescriptor |
71 | 81 | (fn [target prop] desc)} |
72 | 82 | map-handler #js {:get (fn [^cljs.core/ILookup target prop receiver] |
73 | | - (js/__ctor (-lookup target (cache-key-fn prop)))) |
| 83 | + (cond |
| 84 | + (identical? (. Symbol -iterator) prop) |
| 85 | + (unchecked-get target prop) |
| 86 | + |
| 87 | + :else (js/__ctor (-lookup target (cache-key-fn prop))))) |
74 | 88 |
|
75 | 89 | :has (fn [^cljs.core/IAssociative target prop] |
76 | | - (-contains-key? target (cache-key-fn prop))) |
| 90 | + (cond |
| 91 | + (identical? (. Symbol -iterator) prop) true |
| 92 | + :else (-contains-key? target (cache-key-fn prop)))) |
77 | 93 |
|
78 | 94 | :getPrototypeOf |
79 | 95 | (fn [target] nil) |
|
150 | 166 |
|
151 | 167 | (def proxied-deep (proxy [{:foo "Hello"}])) |
152 | 168 | (-> proxied-deep (aget 0) (unchecked-get "foo")) |
| 169 | + |
| 170 | + (aget ((cljs.proxy/builder) [{}]) 0) |
153 | 171 |
|
154 | 172 | ) |
0 commit comments