diff --git a/src/language-html/conditional-comment.js b/src/language-html/conditional-comment.js
new file mode 100644
index 000000000000..3071d310de28
--- /dev/null
+++ b/src/language-html/conditional-comment.js
@@ -0,0 +1,80 @@
+"use strict";
+
+// https://css-tricks.com/how-to-create-an-ie-only-stylesheet
+
+//
+const IE_CONDITIONAL_START_END_COMMENT_REGEX = /^(\[if([^\]]*?)\]>)([\s\S]*?)
+const IE_CONDITIONAL_START_COMMENT_REGEX = /^\[if([^\]]*?)\]>
+const IE_CONDITIONAL_END_COMMENT_REGEX = /^ {
+ try {
+ return [true, parseHtml(data, contentStartSpan).children];
+ } catch (e) {
+ const text = {
+ type: "text",
+ value: data,
+ sourceSpan: new ParseSourceSpan(contentStartSpan, contentEndSpan)
+ };
+ return [false, [text]];
+ }
+ })();
+ return {
+ type: "ieConditionalComment",
+ complete,
+ children,
+ condition: condition.trim().replace(/\s+/g, " "),
+ sourceSpan: node.sourceSpan,
+ startSourceSpan: new ParseSourceSpan(
+ node.sourceSpan.start,
+ contentStartSpan
+ ),
+ endSourceSpan: new ParseSourceSpan(contentEndSpan, node.sourceSpan.end)
+ };
+}
+
+function parseIeConditionalStartComment(node, parseHtml, match) {
+ const [, condition] = match;
+ return {
+ type: "ieConditionalStartComment",
+ condition: condition.trim().replace(/\s+/g, " "),
+ sourceSpan: node.sourceSpan
+ };
+}
+
+function parseIeConditionalEndComment(node /*, parseHtml, match */) {
+ return {
+ type: "ieConditionalEndComment",
+ sourceSpan: node.sourceSpan
+ };
+}
+
+module.exports = {
+ parseIeConditionalComment
+};
diff --git a/src/language-html/parser-html.js b/src/language-html/parser-html.js
index 972088eb4954..cfdcf09ed488 100644
--- a/src/language-html/parser-html.js
+++ b/src/language-html/parser-html.js
@@ -5,6 +5,7 @@ const { HTML_ELEMENT_ATTRIBUTES, HTML_TAGS } = require("./utils");
const { hasPragma } = require("./pragma");
const createError = require("../common/parser-create-error");
const { Node } = require("./ast");
+const { parseIeConditionalComment } = require("./conditional-comment");
function ngHtmlParser(input, canSelfClose) {
const parser = require("angular-html-parser");
@@ -240,50 +241,6 @@ function _parse(
});
}
-function parseIeConditionalComment(node, parseHtml) {
- if (!node.value) {
- return null;
- }
-
- const match = node.value.match(
- /^(\[if([^\]]*?)\]>)([\s\S]*?) {
- try {
- return [true, parseHtml(data, contentStartSpan).children];
- } catch (e) {
- const text = {
- type: "text",
- value: data,
- sourceSpan: new ParseSourceSpan(contentStartSpan, contentEndSpan)
- };
- return [false, [text]];
- }
- })();
- return {
- type: "ieConditionalComment",
- complete,
- children,
- condition: condition.trim().replace(/\s+/g, " "),
- sourceSpan: node.sourceSpan,
- startSourceSpan: new ParseSourceSpan(
- node.sourceSpan.start,
- contentStartSpan
- ),
- endSourceSpan: new ParseSourceSpan(contentEndSpan, node.sourceSpan.end)
- };
-}
-
function locStart(node) {
return node.sourceSpan.start.offset;
}
diff --git a/src/language-html/preprocess.js b/src/language-html/preprocess.js
index c94ed7450e92..5a645e657ce9 100644
--- a/src/language-html/preprocess.js
+++ b/src/language-html/preprocess.js
@@ -12,6 +12,7 @@ const {
const PREPROCESS_PIPELINE = [
removeIgnorableFirstLf,
+ mergeIeConditonalStartEndCommentIntoElementOpeningTag,
mergeCdataIntoText,
extractInterpolation,
extractWhitespaces,
@@ -52,6 +53,70 @@ function removeIgnorableFirstLf(ast /*, options */) {
});
}
+function mergeIeConditonalStartEndCommentIntoElementOpeningTag(
+ ast /*, options */
+) {
+ /**
+ *
+ + + + +
+
+