Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Each iteration over sparse arrays incorrectly executes on deleted entries #1065

Closed
BackupForce opened this issue Jul 24, 2015 · 3 comments
Closed
Labels
Milestone

Comments

@BackupForce
Copy link

I got an arraydata like this { rocords:[{Number:'1',Name:'test1'},{Number:'2',Name:'test2},{Number:'3',Name:'test3}] };
registerHelper like this
Handlebars.registerHelper('link', function (options) {
return '

' + options.fn(this) + this.Name +'

';
});
I delete array[1];
when registerHelper execute array[1], 'this' ponit window.
Its something wrong?

@kpdecker
Copy link
Collaborator

kpdecker commented Aug 1, 2015

I'm not clear what your issue is here and a live example would help us debug this in a much better fashion. Please create a jsfiddle showing us the unexpected behavior. The contributing doc links to a template that can be used for this.

@BackupForce
Copy link
Author

finally haha
http://jsfiddle.net/InoKu/5ybzdbye/1/

@kpdecker kpdecker added this to the 4.0 milestone Aug 4, 2015
@kpdecker
Copy link
Collaborator

kpdecker commented Aug 4, 2015

Thanks for the fiddle, it looks like we are iterating over sparse arrays incorrectly. We need to check to see the field exists prior to running it as an undefined context is not supported (outside of javascript strict mode). Will be fixed in the next release.

@kpdecker kpdecker changed the title when using registerHelper with an arraydata that had been delete. Each iteration over space arrays incorrectly executes on delete entries Aug 4, 2015
@kpdecker kpdecker changed the title Each iteration over space arrays incorrectly executes on delete entries Each iteration over sparse arrays incorrectly executes on deleted entries Aug 4, 2015
flenter pushed a commit to flenter/handlebars.js that referenced this issue Aug 27, 2015
travnels added a commit to travnels/handlebars.js that referenced this issue Jan 16, 2017
handlebars-lang#1227

[undefined, undefined] should have the same behavior as new Array(2),
per handlebars-lang#1065
travnels added a commit to travnels/handlebars.js that referenced this issue Jan 16, 2017
handlebars-lang#1227

[undefined, undefined] should have the same behavior as new Array(2),
per handlebars-lang#1065
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants