A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/bootstrap-vue/bootstrap-vue/commit/b22829d064b6e3820ef66168ec766a57520f31eb below:

Allow empty `alt` prop (fixes #5524) (#5545) · bootstrap-vue/bootstrap-vue@b22829d · GitHub

File tree Expand file treeCollapse file tree 7 files changed

+98

-7

lines changed

Filter options

Expand file treeCollapse file tree 7 files changed

+98

-7

lines changed Original file line number Diff line number Diff line change

@@ -202,7 +202,7 @@ export const BAvatar = /*#__PURE__*/ Vue.extend({

202 202

} = this

203 203

const link = !button && isLink(this)

204 204

const tag = button ? BButton : link ? BLink : 'span'

205 -

const alt = this.alt || null

205 +

const alt = this.alt

206 206

const ariaLabel = this.ariaLabel || null

207 207 208 208

let $content = null

Original file line number Diff line number Diff line change

@@ -317,4 +317,34 @@ describe('avatar', () => {

317 317 318 318

wrapper2.destroy()

319 319

})

320 + 321 +

it('should render `alt` attribute if `alt` prop is empty string', async () => {

322 +

const wrapper = mount(BAvatar, {

323 +

propsData: {

324 +

src: '/foo/bar',

325 +

alt: ''

326 +

}

327 +

})

328 +

expect(wrapper.vm).toBeDefined()

329 +

expect(wrapper.find('img').exists()).toBe(true)

330 +

expect(wrapper.find('img').attributes('src')).toEqual('/foo/bar')

331 +

expect(wrapper.find('img').attributes('alt')).toEqual('')

332 + 333 +

wrapper.destroy()

334 +

})

335 + 336 +

it('should not render `alt` attribute if `alt` prop is null', async () => {

337 +

const wrapper = mount(BAvatar, {

338 +

propsData: {

339 +

src: '/foo/bar',

340 +

alt: null

341 +

}

342 +

})

343 +

expect(wrapper.vm).toBeDefined()

344 +

expect(wrapper.find('img').exists()).toBe(true)

345 +

expect(wrapper.find('img').attributes('src')).toEqual('/foo/bar')

346 +

expect(wrapper.find('img').attributes('alt')).not.toBeDefined()

347 + 348 +

wrapper.destroy()

349 +

})

320 350

})

Original file line number Diff line number Diff line change

@@ -154,6 +154,22 @@ describe('card-image', () => {

154 154

wrapper.destroy()

155 155

})

156 156 157 +

it('has attribute alt when prop `alt` is empty', async () => {

158 +

const wrapper = mount(BCardImgLazy, {

159 +

context: {

160 +

props: {

161 +

src: 'https://picsum.photos/600/300/?image=25',

162 +

alt: ''

163 +

}

164 +

}

165 +

})

166 + 167 +

expect(wrapper.attributes('alt')).toBeDefined()

168 +

expect(wrapper.attributes('alt')).toBe('')

169 + 170 +

wrapper.destroy()

171 +

})

172 + 157 173

it('has attribute width when prop width set', async () => {

158 174

const wrapper = mount(BCardImgLazy, {

159 175

context: {

Original file line number Diff line number Diff line change

@@ -7,8 +7,8 @@ export const props = {

7 7

required: true

8 8

},

9 9

alt: {

10 -

type: String

11 -

// default: null

10 +

type: String,

11 +

default: null

12 12

},

13 13

top: {

14 14

type: Boolean,

@@ -69,7 +69,7 @@ export const BCardImg = /*#__PURE__*/ Vue.extend({

69 69

class: [baseClass],

70 70

attrs: {

71 71

src: props.src || null,

72 -

alt: props.alt || null,

72 +

alt: props.alt,

73 73

height: props.height || null,

74 74

width: props.width || null

75 75

}

Original file line number Diff line number Diff line change

@@ -158,6 +158,22 @@ describe('card-image', () => {

158 158

wrapper.destroy()

159 159

})

160 160 161 +

it('has attribute alt when prop `alt` is empty', async () => {

162 +

const wrapper = mount(BCardImg, {

163 +

context: {

164 +

props: {

165 +

src: 'https://picsum.photos/600/300/?image=25',

166 +

alt: ''

167 +

}

168 +

}

169 +

})

170 + 171 +

expect(wrapper.attributes('alt')).toBeDefined()

172 +

expect(wrapper.attributes('alt')).toBe('')

173 + 174 +

wrapper.destroy()

175 +

})

176 + 161 177

it('has attribute width when prop width set', async () => {

162 178

const wrapper = mount(BCardImg, {

163 179

context: {

Original file line number Diff line number Diff line change

@@ -33,8 +33,8 @@ export const props = {

33 33

// default: null

34 34

},

35 35

alt: {

36 -

type: String

37 -

// default: null

36 +

type: String,

37 +

default: null

38 38

},

39 39

width: {

40 40

type: [Number, String]

@@ -153,7 +153,7 @@ export const BImg = /*#__PURE__*/ Vue.extend({

153 153

mergeData(data, {

154 154

attrs: {

155 155

src: src,

156 -

alt: props.alt || null,

156 +

alt: props.alt,

157 157

width: width ? toString(width) : null,

158 158

height: height ? toString(height) : null,

159 159

srcset: srcset || null,

Original file line number Diff line number Diff line change

@@ -30,6 +30,22 @@ describe('img', () => {

30 30

wrapper.destroy()

31 31

})

32 32 33 +

it('default does not have attributes alt, width, or height', async () => {

34 +

const wrapper = mount(BImg, {

35 +

context: {

36 +

props: {

37 +

src: 'https://picsum.photos/600/300/?image=25'

38 +

}

39 +

}

40 +

})

41 + 42 +

expect(wrapper.attributes('alt')).not.toBeDefined()

43 +

expect(wrapper.attributes('width')).not.toBeDefined()

44 +

expect(wrapper.attributes('height')).not.toBeDefined()

45 + 46 +

wrapper.destroy()

47 +

})

48 + 33 49

it('should have class "img-fluid" when prop fluid set', async () => {

34 50

const wrapper = mount(BImg, {

35 51

propsData: {

@@ -223,4 +239,17 @@ describe('img', () => {

223 239 224 240

wrapper.destroy()

225 241

})

242 + 243 +

it('should have alt attribute when `alt` prop is empty', async () => {

244 +

const wrapper = mount(BImg, {

245 +

propsData: {

246 +

alt: ''

247 +

}

248 +

})

249 + 250 +

expect(wrapper.attributes('alt')).toBeDefined()

251 +

expect(wrapper.attributes('alt')).toEqual('')

252 + 253 +

wrapper.destroy()

254 +

})

226 255

})

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