Skip to content

oget fails if the JS object has :constructor set to null #31

@p-himik

Description

@p-himik
=> (oget #js {:constructor nil, :a 1} :a)
TypeError: Cannot read properties of null (reading 'prototype')
    at Object.oops$helpers$is_prototype_QMARK_ [as is_prototype_QMARK_] (helpers.cljs:7)
    at Object.oops$helpers$cljs_type_QMARK_ [as cljs_type_QMARK_] (helpers.cljs:19)
    at Object.oops$core$validate_object_access_dynamically [as validate_object_access_dynamically] (core.cljs:39)
    at eval (views.cljs:308)

The culprit seems to be this function:

(defn is-prototype? [o]
  (identical? (.-prototype (.-constructor o)) o))

Perhaps it should check if (.-constructor o) is not null?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions