+5722
-9
lines changedFilter options
+5722
-9
lines changed Original file line number Diff line number Diff line change
@@ -7,6 +7,10 @@ import { toFloat } from '../../utils/number'
7
7
8
8
// Common icon props (should be cloned/spread before using)
9
9
export const commonIconProps = {
10
+
title: {
11
+
type: String
12
+
// default: null
13
+
},
10
14
variant: {
11
15
type: String,
12
16
default: null
@@ -132,6 +136,8 @@ export const BVIconBase = /*#__PURE__*/ Vue.extend({
132
136
$inner = h('g', {}, [$inner])
133
137
}
134
138
139
+
const $title = props.title ? h('title', props.title) : null
140
+
135
141
return h(
136
142
'svg',
137
143
mergeData(
@@ -156,7 +162,7 @@ export const BVIconBase = /*#__PURE__*/ Vue.extend({
156
162
}
157
163
}
158
164
),
159
-
[$inner]
165
+
[$title, $inner]
160
166
)
161
167
}
162
168
})
Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@ export const makeIcon = (name, content) => {
16
16
const kebabName = kebabCase(name)
17
17
const iconName = `BIcon${pascalCase(name)}`
18
18
const iconNameClass = `bi-${kebabName}`
19
+
const iconTitle = kebabName.replace(/-/g, ' ')
19
20
const svgContent = trim(content || '')
20
21
// Return the icon component definition
21
22
return /*#__PURE__*/ Vue.extend({
@@ -31,11 +32,20 @@ export const makeIcon = (name, content) => {
31
32
render(h, { data, props }) {
32
33
return h(
33
34
BVIconBase,
34
-
mergeData(data, {
35
-
staticClass: iconNameClass,
36
-
props: { ...props, content: svgContent },
37
-
attrs: { 'aria-label': kebabName.replace(/-/g, ' ') }
38
-
})
35
+
mergeData(
36
+
// Defaults
37
+
{
38
+
props: { title: iconTitle },
39
+
attrs: { 'aria-label': iconTitle }
40
+
},
41
+
// User data
42
+
data,
43
+
// Required data
44
+
{
45
+
staticClass: iconNameClass,
46
+
props: { ...props, content: svgContent }
47
+
}
48
+
)
39
49
)
40
50
}
41
51
})
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
1
1
// --- BEGIN AUTO-GENERATED FILE ---
2
2
//
3
3
// @IconsVersion: 1.0.0
4
-
// @Generated: 2020-09-01T12:06:08.751Z
4
+
// @Generated: 2020-09-03T14:07:12.302Z
5
5
//
6
6
// This file is generated on each build. Do not edit this file!
7
7
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
1
1
// --- BEGIN AUTO-GENERATED FILE ---
2
2
//
3
3
// @IconsVersion: 1.0.0
4
-
// @Generated: 2020-09-01T12:06:08.751Z
4
+
// @Generated: 2020-09-03T14:07:12.302Z
5
5
//
6
6
// This file is generated on each build. Do not edit this file!
7
7
Original file line number Diff line number Diff line change
@@ -502,4 +502,46 @@ describe('icons', () => {
502
502
503
503
wrapper.destroy()
504
504
})
505
+
506
+
it('b-icon title prop works', async () => {
507
+
const wrapper = mount(BIcon, {
508
+
localVue,
509
+
propsData: {
510
+
icon: 'circle-fill',
511
+
title: 'Circle'
512
+
}
513
+
})
514
+
515
+
expect(wrapper.exists()).toBe(true)
516
+
expect(wrapper.element.tagName).toBe('svg')
517
+
expect(wrapper.classes()).toContain('b-icon')
518
+
expect(wrapper.classes()).toContain('bi')
519
+
expect(wrapper.classes()).toContain('bi-circle-fill')
520
+
521
+
const $title = wrapper.find('title')
522
+
expect($title.exists()).toBe(true)
523
+
expect($title.text()).toBe('Circle')
524
+
525
+
wrapper.destroy()
526
+
})
527
+
528
+
it('b-icon <title> should not render when title is undefined', async () => {
529
+
const wrapper = mount(BIcon, {
530
+
localVue,
531
+
propsData: {
532
+
icon: 'circle-fill'
533
+
}
534
+
})
535
+
536
+
expect(wrapper.exists()).toBe(true)
537
+
expect(wrapper.element.tagName).toBe('svg')
538
+
expect(wrapper.classes()).toContain('b-icon')
539
+
expect(wrapper.classes()).toContain('bi')
540
+
expect(wrapper.classes()).toContain('bi-circle-fill')
541
+
542
+
const $title = wrapper.find('title')
543
+
expect($title.exists()).toBe(false)
544
+
545
+
wrapper.destroy()
546
+
})
505
547
})
Original file line number Diff line number Diff line change
@@ -118,4 +118,44 @@ describe('icons > b-iconstack', () => {
118
118
119
119
wrapper.destroy()
120
120
})
121
+
122
+
it('b-iconstack title prop works', async () => {
123
+
const wrapper = mount(BIconstack, {
124
+
propsData: {
125
+
icon: 'circle-fill',
126
+
title: 'Circle'
127
+
}
128
+
})
129
+
130
+
expect(wrapper.exists()).toBe(true)
131
+
expect(wrapper.element.tagName).toBe('svg')
132
+
expect(wrapper.classes()).toContain('b-icon')
133
+
expect(wrapper.classes()).toContain('b-iconstack')
134
+
expect(wrapper.classes()).toContain('bi')
135
+
136
+
const $title = wrapper.find('title')
137
+
expect($title.exists()).toBe(true)
138
+
expect($title.text()).toBe('Circle')
139
+
140
+
wrapper.destroy()
141
+
})
142
+
143
+
it('b-iconstack <title> should not render when title is undefined', async () => {
144
+
const wrapper = mount(BIconstack, {
145
+
propsData: {
146
+
icon: 'circle-fill'
147
+
}
148
+
})
149
+
150
+
expect(wrapper.exists()).toBe(true)
151
+
expect(wrapper.element.tagName).toBe('svg')
152
+
expect(wrapper.classes()).toContain('b-icon')
153
+
expect(wrapper.classes()).toContain('b-iconstack')
154
+
expect(wrapper.classes()).toContain('bi')
155
+
156
+
const $title = wrapper.find('title')
157
+
expect($title.exists()).toBe(false)
158
+
159
+
wrapper.destroy()
160
+
})
121
161
})
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4