1

I'm wondering if it is possible to get a HTML element's property listed in the Event Listeners tab?

Event Listeners tab

The console command

getEventListeners(window.document.activeElement) 

gives the full list.

But is it possible to get the above displayed property _oRecord through its "property path"?

A right click in the browser allows me to copy the property path, i.e. [""0""].P._oRecord in my case.

With getEventListeners(), I can get the function, while I need to get one of the "[[Scopes]]" properties.

Expanded event listeners object tree

try-catch-finally
  • 7,436
  • 6
  • 46
  • 67
Stéphane GROSSMANN
  • 369
  • 2
  • 5
  • 14
  • `[[Scope]]` is an internal property of the Javascript engine. It's probably only/exclusively exposed by the dev tools UI. It's not meant to be accessible via Javascript itself. To be sure: you want to access that property programmatically, via a script in the console; inspection via the panel is not sufficient for you? Please clarify that, your text is a bit ambiguous. [X/Y problem](https://meta.stackexchange.com/questions/66377/what-is-the-xy-problem): why so you want to access that property via the console, what do you want to achieve/solve? – try-catch-finally Dec 28 '18 at 14:34
  • The page I need to analyse, displays a big array of lines, and each line opens a textarea. I'm trying to make the link between the textarea which is open when the user clicks in the line, and the line itself. – Stéphane GROSSMANN Dec 29 '18 at 15:13
  • I hope you want to make the "link" (connection) between both just for debugging not for production. Note that `getEventListeners()` is only a Chrome developer tools function, not available to the page's code and possibly not available to other browser tools at all. If debugging: consider this tip: attach the event listener to the common parent element and examine `target` to know the actual element in the event object to spare you managing dozens of event listeners (search this site or google for "event delegation"). – try-catch-finally Dec 29 '18 at 15:35

1 Answers1

0

[[Scopes]] is an internal property of the Javascript engine. It's only exposed to the developer tools.

You can't access this property programmatically via Javascript.

Though what you could do is, manually storing the object as global variable and inspect it programmatically:

Store as variable

(Right-click on [[Scopes]])

Say it has been stored as temp1, then this would allow you to further inspect the scope information programmatically:

Object.values(temp1).map((s) => s.object)
try-catch-finally
  • 7,436
  • 6
  • 46
  • 67