Skip to content
GitLab
    • Explore Projects Groups Snippets
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • B bootstrap
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 263
    • Issues 263
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 114
    • Merge requests 114
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Bootstrap
  • bootstrap
  • Merge requests
  • !29609
An error occurred while fetching the assigned milestone of the selected merge_request.

Update normalizeDataKey to match the spec

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Administrator requested to merge github/fork/MisatoTremor/patch-1 into master 5 years ago
  • Overview 1
  • Commits 2
  • Pipelines 0
  • Changes 2

Created by: MisatoTremor

See https://html.spec.whatwg.org/multipage/dom.html#dom-dataset

Compare
  • master (base)

and
  • latest version
    bbadacb4
    2 commits, 2 years ago

2 files
+ 11
- 11

    Preferences

    File browser
    Compare changes
j‎s‎
src‎/dom‎
manipul‎ator.js‎ +1 -1
tests/u‎nit/dom‎
manipulat‎or.spec.js‎ +10 -10
js/src/dom/manipulator.js
+ 1
- 1
  • View file @ bbadacb4

  • Edit in single-file editor

  • Open in Web IDE


@@ -26,7 +26,7 @@ function normalizeData(val) {
}
function normalizeDataKey(key) {
return key.replace(/[A-Z]/g, chr => chr.toLowerCase())
return key.replace(/[A-Z]/g, chr => `-${chr.toLowerCase()}`)
}
const Manipulator = {
js/tests/unit/dom/manipulator.spec.js
+ 10
- 10
  • View file @ bbadacb4

  • Edit in single-file editor

  • Open in Web IDE


@@ -24,13 +24,13 @@ describe('Manipulator', () => {
expect(div.getAttribute('data-key')).toEqual('value')
})
it('should set data attribute in lower case', () => {
it('should set data attribute in kebab case', () => {
fixtureEl.innerHTML = '<div></div>'
const div = fixtureEl.querySelector('div')
Manipulator.setDataAttribute(div, 'tEsT', 'value')
expect(div.getAttribute('data-test')).toEqual('value')
Manipulator.setDataAttribute(div, 'testKey', 'value')
expect(div.getAttribute('data-test-key')).toEqual('value')
})
})
@@ -44,13 +44,13 @@ describe('Manipulator', () => {
expect(div.getAttribute('data-key')).toBeNull()
})
it('should remove data attribute in lower case', () => {
fixtureEl.innerHTML = '<div data-testkey="value" ></div>'
it('should remove data attribute in kebab case', () => {
fixtureEl.innerHTML = '<div data-test-key="value"></div>'
const div = fixtureEl.querySelector('div')
Manipulator.removeDataAttribute(div, 'tEStKeY')
expect(div.getAttribute('data-testkey')).toBeNull()
Manipulator.removeDataAttribute(div, 'testKey')
expect(div.getAttribute('data-test-key')).toBeNull()
})
})
@@ -81,12 +81,12 @@ describe('Manipulator', () => {
expect(Manipulator.getDataAttribute(div, 'test')).toBeNull()
})
it('should get data attribute in lower case', () => {
fixtureEl.innerHTML = '<div data-test="value" ></div>'
it('should get data attribute in kebab case', () => {
fixtureEl.innerHTML = '<div data-test-key="value" ></div>'
const div = fixtureEl.querySelector('div')
expect(Manipulator.getDataAttribute(div, 'tEsT')).toEqual('value')
expect(Manipulator.getDataAttribute(div, 'testKey')).toEqual('value')
})
it('should normalize data', () => {
0 Assignees
None
Assign to
0 Reviewers
None
Request review from
Labels
0
None
0
None
    Assign labels
  • Manage project labels

Milestone
No milestone
None
None
Time tracking
No estimate or time spent
Lock merge request
Unlocked
0
0 participants
Reference:
Source branch: github/fork/MisatoTremor/patch-1

Menu

Explore Projects Groups Snippets