jashkenas / jashkenas/backbone

After using extend function, the child name is not appropriate

Open
#4,079 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

change starter
Dominant language
JavaScript
Stars
28.1k
Forks
5.3k
PR merge metrics
No merged PRs in 30d

Description

As in the definition of var extend = function(protoProps, staticProps) ,
`child = function(){ return parent.apply(this, arguments); };`
the return child function's name is set as 'child'.

Thus, any new object created by the child function, when you inspect them in Chrome, the name of constructor is displayed as 'child'.
![image](https://cloud.githubusercontent.com/assets/5484463/18865690/da5e3704-849c-11e6-9aeb-39b941b75d0a.png)

Would it be better to display the name of constructor using parent constructor's name ?

From my point of view, it gives developers intuitive overview what the object essentially is. In previous case, "Backbone.Collection" should be displayed after todos.
![image](https://cloud.githubusercontent.com/assets/5484463/18866868/00622fc8-84a2-11e6-8654-aa457ec9f6c0.png)
Because
![image](https://cloud.githubusercontent.com/assets/5484463/18866853/f3c18c3c-84a1-11e6-8e22-9a5b728c2ac5.png)

I was using the todo list example http://todomvc.com/examples/backbone/

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the extend function definition shown in the issue, especially the child constructor created as `function(){ return parent.apply(this, arguments); }`. Investigate how Backbone's constructor names are exposed in Chrome for objects created through extend; done means the displayed constructor name is more representative of the parent or derived type without breaking existing extend behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
developer-experience
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.