Skip to content

Commit

Permalink
Merge pull request #147 from HubSpot/fix-nested-inline-styles
Browse files Browse the repository at this point in the history
Stop resetting `inlineStyles` in `baseProcessInlineTag`
  • Loading branch information
maxwellskala authored Jul 19, 2019
2 parents e96004b + de223b1 commit dfa2722
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/convertFromHTML.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,8 @@ function processInlineTag(tag, node, currentStyle) {
return currentStyle;
}

function baseProcessInlineTag(tag, node) {
return processInlineTag(tag, node, OrderedSet());
function baseProcessInlineTag(tag, node, inlineStyles = OrderedSet()) {
return processInlineTag(tag, node, inlineStyles);
}

function joinChunks(A, B, flat = false) {
Expand Down
12 changes: 12 additions & 0 deletions test/spec/convertFromHTML-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,18 @@ describe('convertFromHTML', () => {
testFixture('<p><strong>draft<u>JS</u></strong></p>');
});

it('nested inline styles - with naive middleware htmlToStyle', () => {
const htmlIn = '<p><strong><u>Boo</u></strong></p>';
const defaultMiddlewareFunction = next => (...args) => next(...args);
defaultMiddlewareFunction.__isMiddleware = true;

const contentState = convertFromHTML({
htmlToStyle: defaultMiddlewareFunction,
})(htmlIn);
const htmlOut = convertToHTML(contentState);
expect(htmlOut).toEqual(htmlIn);
});

it('empty paragraphs', () => {
const htmlFixture = '<p>one</p><p></p><p>two</p>';
const state = convertFromHTML(htmlFixture);
Expand Down

0 comments on commit dfa2722

Please sign in to comment.