Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use of aget breaks under advanced compilation #84

Closed
viesti opened this issue Oct 27, 2023 · 2 comments
Closed

Use of aget breaks under advanced compilation #84

viesti opened this issue Oct 27, 2023 · 2 comments

Comments

@viesti
Copy link
Contributor

viesti commented Oct 27, 2023

Hickory uses aget for example in

(defn node-type
  [type]
  (aget goog.dom.NodeType type))

which, which current ClojurScript, breaks under advanced compilation, since property names are munged.

Under advanced compilation:

(println "hickory goog.dom.NodeType" goog.dom.NodeType)
=>
hickory goog.dom.NodeType #js {:Fi 1, :zi 2, :Ki 3, :Ai 4, :Hi 5, :Gi 6, :Ji 7, :Bi 8, :Ci 9, :Ei 10, :Di 11, :Ii 12}

when not using advanced compilation:

(println "hickory goog.dom.NodeType" goog.dom.NodeType)
=>
hickory goog.dom.NodeType #js {:ELEMENT 1, :ATTRIBUTE 2, :TEXT 3, :CDATA_SECTION 4, :ENTITY_REFERENCE 5, :ENTITY 6, :PROCESSING_INSTRUCTION 7, :COMMENT 8, :DOCUMENT 9, :DOCUMENT_TYPE 10, :DOCUMENT_FRAGMENT 11, :NOTATION 12}

Should probably use just .- property access instead of aget. aget probably has worked with older ClojureScript, but doesn't work any longer.

@viesti
Copy link
Contributor Author

viesti commented Oct 27, 2023

Or actually, goog.object/get, as suggested in docs:

(require 'goog.object)
(def obj #js {:foo #js {:bar 2}})

(goog.object/get obj "foo")
;;=> #js {:bar 2} 

@danielcompton
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants