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

Current interop issue: some browsers use displayName property #14

Open
domenic opened this issue Oct 20, 2017 · 4 comments
Open

Current interop issue: some browsers use displayName property #14

domenic opened this issue Oct 20, 2017 · 4 comments

Comments

@domenic
Copy link
Member

domenic commented Oct 20, 2017

They should only be using name these days, but some still keep it around. Would be good to standardize on this being disallowed and write tests as such.

@ljharb
Copy link
Member

ljharb commented Mar 15, 2019

@domenic sorry for the delay here; can you elaborate on exactly how (and which) some browsers use this property?

@domenic
Copy link
Member Author

domenic commented Mar 15, 2019

Some browsers use the displayName property of a function, instead of using the function's name property, in stack traces.

As for exactly which, I have the time to raise a known issue for the proposal champions, but not to do the research required to drive the proposal, since I am not a champion myself.

@ljharb
Copy link
Member

ljharb commented Mar 15, 2019

Thanks; looks like Safari, at least, shows g with:

function f() { return new Error(); }
f.displayName = 'g';
f().stack;

Chrome and Firefox and IE 11 and Edge do not.

cc @msaboff @kmiller68 @erights

@loganfsmyth
Copy link

For Firefox/SpiderMonkey, there's also reason to clearly define expectations here because when there is no "name" for a function, SpiderMonkey currently attempts to provide a useful description of where the anonymous function is declared, for example:

function parent() {
  return (() => {
    return new Error().stack;
  })();
}
parent();

results in

parent/<@debugger eval code:3:12
parent@debugger eval code:4:5
@debugger eval code:6:1

with parent/< representing "an anonymous function defined inside 'parent'". There's also other cases like

function parent() {
  return {
    prop: (() => {
      return new Error().stack;
    })()
  }.prop;
}
parent();

which output

parent/<.prop<@debugger eval code:4:14
parent@debugger eval code:5:7
@debugger eval code:8:1

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

No branches or pull requests

3 participants