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

Omitting deleteCount, this.splice() acts different from array.splice() #5032

Closed
2 of 6 tasks
4d4841 opened this issue Jan 10, 2018 · 1 comment · Fixed by #5051
Closed
2 of 6 tasks

Omitting deleteCount, this.splice() acts different from array.splice() #5032

4d4841 opened this issue Jan 10, 2018 · 1 comment · Fixed by #5051
Assignees
Labels

Comments

@4d4841
Copy link

4d4841 commented Jan 10, 2018

Description

Should this.splice('thisArray', 0) remove all entries? "If deleteCount is omitted ... then all of the elements from start through the end of the array will be deleted." https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice

Live Demo

http://jsbin.com/wogogaseya/1/edit?html,output

Steps to Reproduce

    let arrgh = [1,2,3];
    this.arrgh = [1,2,3];
    arrgh.splice(0);
    this.splice('arrgh',0);
    console.log('Lengths:',arrgh.length,this.arrgh.length);

// Lengths: 0 3

https://github.com/Polymer/polymer/blob/master/lib/mixins/property-effects.html#L1942

Expected Results

Lengths: 0 0

Actual Results

Lengths: 0 3

Browsers Affected

  • Chrome
  • Firefox
  • Edge
  • Safari 9
  • Safari 8
  • IE 11

Versions

  • Polymer: vX.X.X
  • webcomponents: vX.X.X
@4d4841 4d4841 changed the title this.splice() acts different from array.splice() Omitting deleteCount, this.splice() acts different from array.splice() Jan 10, 2018
@kevinpschaaf
Copy link
Member

Yes, the intention is that they match the native API, so that is an oversight.

@TimvdLippe do you want to take a crack at a fix for Polymer 2?

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

Successfully merging a pull request may close this issue.

3 participants