Browse Source

Improve table cells for xml parser

pull/3691/head
Artur Arseniev 5 years ago
parent
commit
e9ca7fe1dc
  1. 15
      src/dom_components/model/ComponentTableCell.js
  2. 7
      test/specs/dom_components/model/ComponentTypes.js

15
src/dom_components/model/ComponentTableCell.js

@ -1,4 +1,5 @@
import Component from './Component';
import { toLowerCase } from 'utils/mixins';
export default Component.extend(
{
@ -10,18 +11,6 @@ export default Component.extend(
}
},
{
isComponent(el) {
let result = '';
const tag = el.tagName;
if (tag == 'TD' || tag == 'TH') {
result = {
type: 'cell',
tagName: tag.toLowerCase()
};
}
return result;
}
isComponent: el => ['td', 'th'].indexOf(toLowerCase(el.tagName)) >= 0
}
);

7
test/specs/dom_components/model/ComponentTypes.js

@ -6,7 +6,7 @@ describe('Component Types', () => {
const expectedType = (input, type, opts = {}) => {
const cmp = wrapper.append(input)[0];
expect(wrapper.components().length).toBe(1);
expect(wrapper.components().length).toBe(opts.total || 1);
!opts.skipHtml && expect(cmp.toHTML()).toBe(input);
expect(cmp.is(type)).toBe(true);
};
@ -48,6 +48,11 @@ describe('Component Types', () => {
expectedType('<tbody></tbody>', 'tbody', { skipHtml: 1 });
});
test('<td> & <th> are correctly recognized', () => {
expectedType('<td></td>', 'cell');
expectedType('<th></th>', 'cell', { total: 2 });
});
test('<script> is correctly recognized', () => {
// const scr = 'console.log("Inline script");'; // issues with jsdom parser
const scr = ``;

Loading…
Cancel
Save