Skip to content

Commit ab230ef

Browse files
committed
Revert parse5 v htmlparser2 conditions
htmlparser2 supports parse5 interface now
1 parent 0dc010f commit ab230ef

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

lib/inline.js

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -251,15 +251,15 @@ function inlineDocument($, css, options) {
251251
props.sort(function(a, b) {
252252
return a.compareFunc(b);
253253
});
254-
254+
255255
var string = props
256256
.filter(function(prop) {
257257

258258
// don't add css variables if we're resolving their values
259259
if (options.resolveCSSVariables && (prop.prop.indexOf('--') === 0) ) {
260260
return false;
261261
}
262-
262+
263263
// Content becomes the innerHTML of pseudo elements, not used as a
264264
// style property
265265
return (prop.prop !== 'content');
@@ -469,10 +469,7 @@ function getStylesData($, options) {
469469
var styleDataList, styleData, styleElement;
470470
stylesList.each(function() {
471471
styleElement = this;
472-
// the API for Cheerio using parse5 (default) and htmlparser2 are slightly different
473-
// detect this by checking if .childNodes exist (as opposed to .children)
474-
var usingParse5 = !!styleElement.childNodes;
475-
styleDataList = usingParse5 ? styleElement.childNodes : styleElement.children;
472+
styleDataList = styleElement.childNodes;
476473
if (styleDataList.length !== 1) {
477474
if (options.removeStyleTags) {
478475
$(styleElement).remove();
@@ -484,19 +481,15 @@ function getStylesData($, options) {
484481
results.push(styleData);
485482
}
486483
if (options.removeStyleTags && $(styleElement).attr('data-embed') === undefined) {
487-
var text = usingParse5 ? styleElement.childNodes[0].nodeValue : styleElement.children[0].data;
484+
var text = styleElement.childNodes[0].nodeValue;
488485
var preservedText = utils.getPreservedText(text, {
489486
mediaQueries: options.preserveMediaQueries,
490487
fontFaces: options.preserveFontFaces,
491488
keyFrames: options.preserveKeyFrames,
492489
pseudos: options.preservePseudos
493490
}, juiceClient.ignoredPseudos);
494491
if (preservedText) {
495-
if (usingParse5) {
496-
styleElement.childNodes[0].nodeValue = preservedText;
497-
} else {
498-
styleElement.children[0].data = preservedText;
499-
}
492+
styleElement.childNodes[0].nodeValue = preservedText;
500493
} else {
501494
$(styleElement).remove();
502495
}

0 commit comments

Comments
 (0)