/
githubmirror
/
ionic
Обзор
Документация
Войти
/
githubmirror
/
ionic
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
core/src/utils/test/attributes.spec.ts
65 строк
2 KB
Sean Perkins
fix(core): inherit aria attributes on host elements (#25156)
21 апр 2022, 17:50
Не верифицирован
21 апр 2022, 17:50
611832b
Код
Авторство
О чём код?
import { inheritAttributes, inheritAriaAttributes } from '../helpers'; describe('inheritAttributes()', () => { it('should create an attribute inheritance object', () => { const el = document.createElement('div'); el.setAttribute('tabindex', '20'); el.setAttribute('title', 'myTitle'); const attributeObject = inheritAttributes(el, ['tabindex', 'title']); expect(attributeObject).toEqual({ tabindex: '20', title: 'myTitle', }); }); it('should not inherit attributes that are not defined on the element', () => { const el = document.createElement('div'); el.setAttribute('tabindex', '20'); const attributeObject = inheritAttributes(el, ['tabindex', 'title']); expect(attributeObject).toEqual({ tabindex: '20', }); }); it('should not inherit attributes that are not defined on the input array', () => { const el = document.createElement('div'); el.setAttribute('tabindex', '20'); el.setAttribute('title', 'myTitle'); const attributeObject = inheritAttributes(el, ['title']); expect(attributeObject).toEqual({ title: 'myTitle', }); }); }); describe('inheritAriaAttributes()', () => { it('should inherit ARIA attributes defined on the HTML element', () => { const el = document.createElement('div'); el.setAttribute('aria-label', 'myLabel'); el.setAttribute('aria-describedby', 'myDescription'); const attributeObject = inheritAriaAttributes(el); expect(attributeObject).toEqual({ 'aria-label': 'myLabel', 'aria-describedby': 'myDescription', }); }); it('should inherit the role attribute defined on the HTML element', () => { const el = document.createElement('div'); el.setAttribute('role', 'button'); const attributeObject = inheritAriaAttributes(el); expect(attributeObject).toEqual({ role: 'button', }); }); });