Skip to content
This repository has been archived by the owner on Dec 30, 2022. It is now read-only.

Commit

Permalink
perf: use unique keys in all v-for loops
Browse files Browse the repository at this point in the history
  • Loading branch information
rayrutjes committed Aug 5, 2017
1 parent 271a113 commit fdbf56a
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/components/Pagination.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<slot name="previous">&lt;</slot>
</a>
</li>
<li v-for="(item, key) in pages" :key="key" :class="[bem('item'), page === item ? bem('item', 'active') : '']" >
<li v-for="item in pages" :key="item" :class="[bem('item'), page === item ? bem('item', 'active') : '']" >
<a href="#" @click.prevent="goToPage(item)">
<slot :value="item" :active="item === page">
{{ item }}
Expand Down
6 changes: 3 additions & 3 deletions src/components/Rating.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
:max="max"
:count="facet.count"
>
<template v-for="(n, key) in max">
<span v-if="n <= facet.value" :class="bem('star')" :key="key">&#9733;</span>
<span v-else :class="bem('star', 'empty')" :key="key">&#9734;</span>
<template v-for="n in max">
<span v-if="n <= facet.value" :class="bem('star')" :key="n">&#9733;</span>
<span v-else :class="bem('star', 'empty')" :key="n">&#9734;</span>
</template>
&nbsp;&amp; up
<span :class="bem('count')">{{facet.count}}</span>
Expand Down
2 changes: 1 addition & 1 deletion src/components/RefinementList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<slot name="header"></slot>

<div v-for="(facet, key) in facetValues" :key="key" :class="[bem('item'), facet.isRefined ? bem('item', 'active') : '']">
<div v-for="facet in facetValues" :key="facet.name" :class="[bem('item'), facet.isRefined ? bem('item', 'active') : '']">
<label :class="bem('label')">
<input type="checkbox"
:class="bem('checkbox')"
Expand Down
2 changes: 1 addition & 1 deletion src/components/Results.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<slot name="header"></slot>

<slot v-for="(result, key) in results" :result="result" :key="key">
<slot v-for="result in results" :result="result" :key="result.objectID">
Result 'objectID': {{ result.objectID }}
</slot>

Expand Down
4 changes: 2 additions & 2 deletions src/components/ResultsPerPageSelector.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<select :class="bem()" v-model="resultsPerPage">
<template v-for="(option, key) in options">
<option :value="option" :key="key"><slot :option="option">{{ option }}</slot></option>
<template v-for="option in options">
<option :value="option" :key="option"><slot :option="option">{{ option }}</slot></option>
</template>
</select>
</template>
Expand Down
2 changes: 1 addition & 1 deletion src/components/SortBySelector.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<select :class="bem()" v-model="indexName">
<slot v-for="index in indices" :indexName="index.name" :label="index.label">
<option :value="index.name">
<option :value="index.name" :key="index.name">
{{ index.label }}
</option>
</slot>
Expand Down

0 comments on commit fdbf56a

Please sign in to comment.