Skip to main content

has_trap

Function has_trap 

Source
pub fn has_trap(v: &Value, name: &str) -> bool
Expand description

Resolve trap name on v’s handler.

Ok(None) means “not a proxy, or no such trap” — the caller runs its ordinary path (against the target, for the no-trap case). A revoked proxy and a non-callable trap both throw here, before any target work happens. Whether this proxy’s handler installs name as a callable trap.

Distinguishes “the trap answered, and this is its answer” from “there is no trap, so the read forwarded to the target” — the two are indistinguishable in the returned value, and ToPrimitive has to tell them apart: a get trap that hands back a non-callable toString refuses the conversion, while a trapless proxy over a Map brands as its target does.