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

fix(MdTable): emit selected / update event only when selected item(s) really changed #1585

Merged
merged 2 commits into from
Mar 7, 2018

Conversation

VdustR
Copy link
Member

@VdustR VdustR commented Mar 6, 2018

fix #1559

@VdustR VdustR changed the title fix(MdTable): only emit selected / update event when selected item(s) really changed fix(MdTable): emit selected / update event only when selected item(s) really changed Mar 6, 2018
@VdustR
Copy link
Member Author

VdustR commented Mar 7, 2018

Additionally, I want to make another PR to implement model comparing in utils. Maybe named MdModelComparator?

All components have selection could call the function to check the value or array is changed or not, including MdSelect, MdTable, MdRadio.

for single comparing, I want to implement a method compare(a, b) followed these rules:

  • undefined = null
  • null != 0 != NaN != ''
  • 0 = '0', 1 = '1', ...
  • any non-object-value != any object, an object != another object

for multiple comparing, I want to implement a method compareArray(a, b) followed these rules:

  • [] = null = undefined
  • regarding sorting,['a', 'b'] = ['b', 'a'].
    including objects, [a, b] = [b, a]. I'll using find index to implement that.
  • values in array follow single comparing rule, like: [null] = [undefined]

These rules could be write in documentation to let developers know how it work.

@marcosmoura , @Samuell1
How do you think?

@@ -222,11 +222,28 @@
this.MdTable.hasValue = this.hasValue
}
},
'MdTable.selectedItems' (val) {
this.select(val)
'MdTable.selectedItems' (val, old) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this method is way complex. Maybe we can break it in some small functions to better describe it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like: val.length !== old.length) ? true : !val.every((item, index) => item == old[index]

@marcosmoura
Copy link
Member

@VdustR I think it would be good. I want to make less code repetition.

@marcosmoura marcosmoura merged commit a591144 into vuematerial:dev Mar 7, 2018
@VdustR VdustR deleted the fix#1559 branch March 8, 2018 00:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[MdTable] emitting @md-selected with no value
2 participants