diff --git a/index.js b/index.js index c64496f..a1b9bde 100644 --- a/index.js +++ b/index.js @@ -164,7 +164,7 @@ module.exports = (html, options) => { const ampElement = Object.assign(element, { name: `amp-${element.name}`, }); - $(element).replaceWith(ampElement); + $(element).html($(ampElement).html()); }); return $.html(); diff --git a/test/images.test.js b/test/images.test.js index e19f4b5..10da2fc 100644 --- a/test/images.test.js +++ b/test/images.test.js @@ -33,4 +33,12 @@ describe('amp-img tag', () => { { cwd: __dirname.split(path.sep).pop() }, ); }); + + test('should not change element order or remove next element', () => { + assert( + '

1

2

', + '

1

2

', + { cwd: __dirname.split(path.sep).pop() }, + ); + }); });