Skip to content

Commit fa4d8c7

Browse files
committed
fix: return array of classes from classes method
1 parent b263b60 commit fa4d8c7

File tree

4 files changed

+7
-6
lines changed

4 files changed

+7
-6
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
"gitbook-plugin-edit-link": "^2.0.2",
6262
"gitbook-plugin-github": "^3.0.0",
6363
"gitbook-plugin-theme-vuejs": "^1.1.0",
64-
"jsdom": "^11.0.0",
64+
"jsdom": "^11.5.1",
6565
"jsdom-global": "^3.0.2",
6666
"karma": "^1.7.0",
6767
"karma-chrome-launcher": "^2.2.0",

src/lib/create-functional-component.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ export default function createFunctionalComponent (component: Component, mountin
5454
mountingOptions.context || component.FunctionalRenderContext,
5555
(mountingOptions.context && mountingOptions.context.children && mountingOptions.context.children.map(x => typeof x === 'function' ? x(h) : x)) || createFunctionalSlots(mountingOptions.slots, h)
5656
)
57-
}
57+
},
58+
name: component.name
5859
}
5960
}

src/wrappers/wrapper.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export default class Wrapper implements BaseWrapper {
4949
* Returns an Array containing all the classes on the element
5050
*/
5151
classes (): Array<string> {
52-
let classes = [...this.element.classList]
52+
let classes = this.element.className ? this.element.className.split(' ') : []
5353
// Handle converting cssmodules identifiers back to the original class name
5454
if (this.vm && this.vm.$style) {
5555
const cssModuleIdentifiers = {}

test/unit/specs/mount/Wrapper/classes.spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@ describe('classes', () => {
77
it('returns array of class names if wrapper has class names', () => {
88
const compiled = compileToFunctions('<div class="a-class b-class" />')
99
const wrapper = mount(compiled)
10-
expect(wrapper.classes()).to.eql(['a-class', 'b-class'])
10+
expect(wrapper.classes()).to.contain('a-class')
11+
expect(wrapper.classes()).to.contain('b-class')
1112
})
1213

1314
it('returns empty array if wrapper has no classes', () => {
1415
const compiled = compileToFunctions('<div />')
1516
const wrapper = mount(compiled)
16-
expect(wrapper.classes()).to.eql([])
17+
expect(wrapper.classes().length).to.equal(0)
1718
})
1819

1920
it('returns original class names when element mapped in css modules', () => {
2021
const wrapper = mount(ComponentWithCssModules)
21-
2222
expect(wrapper.classes()).to.eql(['extension', 'color-red'])
2323
})
2424
})

0 commit comments

Comments
 (0)