Skip to content

Commit e6bdbdb

Browse files
committed
refactor(files): replace deprecated is attr on <a> with dynamic component
- Special attribute `is` is deprecated and removed in Vue 3 - It is confusing, that `<a>` element is rendered as `span` sometimes Signed-off-by: Grigorii K. Shartsev <me@shgk.me>
1 parent fedd531 commit e6bdbdb

1 file changed

Lines changed: 20 additions & 11 deletions

File tree

apps/files/src/components/FileEntry/FileEntryName.vue

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,20 +37,21 @@
3737
@keyup.esc="stopRenaming" />
3838
</form>
3939

40-
<a v-else
40+
<component :is="linkTo.is"
41+
v-else
4142
ref="basename"
4243
:aria-hidden="isRenaming"
4344
class="files-list__row-name-link"
4445
data-cy-files-list-row-name-link
45-
v-bind="linkTo"
46+
v-bind="linkTo.params"
4647
@click="$emit('click', $event)">
4748
<!-- File name -->
4849
<span class="files-list__row-name-text">
4950
<!-- Keep the displayName stuck to the extension to avoid whitespace rendering issues-->
5051
<span class="files-list__row-name-" v-text="displayName" />
5152
<span class="files-list__row-name-ext" v-text="extension" />
5253
</span>
53-
</a>
54+
</component>
5455
</template>
5556

5657
<script lang="ts">
@@ -137,8 +138,10 @@ export default Vue.extend({
137138
linkTo() {
138139
if (this.source.attributes.failed) {
139140
return {
140-
title: t('files', 'This node is unavailable'),
141141
is: 'span',
142+
params: {
143+
title: t('files', 'This node is unavailable'),
144+
},
142145
}
143146
}
144147
@@ -147,18 +150,24 @@ export default Vue.extend({
147150
const action = enabledDefaultActions[0]
148151
const displayName = action.displayName([this.source], this.currentView)
149152
return {
150-
title: displayName,
151-
role: 'button',
152-
tabindex: '0',
153+
is: 'a',
154+
params: {
155+
title: displayName,
156+
role: 'button',
157+
tabindex: '0',
158+
},
153159
}
154160
}
155161
156162
if (this.source?.permissions & Permission.READ) {
157163
return {
158-
download: this.source.basename,
159-
href: this.source.source,
160-
title: t('files', 'Download file {name}', { name: this.displayName }),
161-
tabindex: '0',
164+
is: 'a',
165+
params: {
166+
download: this.source.basename,
167+
href: this.source.source,
168+
title: t('files', 'Download file {name}', { name: this.displayName }),
169+
tabindex: '0',
170+
},
162171
}
163172
}
164173

0 commit comments

Comments
 (0)