|
var util = require('util'),
_ = require('underscore'),
extendWithGettersAndSetters = require('../util/extendWithGettersAndSetters'),
Relation = require('./Relation'),
HtmlRelation = require('./HtmlRelation');
function HtmlConditionalComment(config) {
if (!('condition' in config)) {
throw new Error("HtmlConditionalComment constructor: 'condition' config option is mandatory.");
}
HtmlRelation.call(this, config);
}
util.inherits(HtmlConditionalComment, HtmlRelation);
extendWithGettersAndSetters(HtmlConditionalComment.prototype, {
inline: function () {
Relation.prototype.inline.call(this);
if (this.isInverted) {
// ... (evaluated by all non-IE browsers)
// ... (evaluated by certain IE versions and all non-IE browsers)
// Clear the existing content between the start and end markers:
while (this.node.nextSibling && this.node.nextSibling !== this.endNode) {
this.node.parentNode.removeChild(this.node.nextSibling);
}
// Create copies of the nodes in the target asset and insert them between the start and end markers:
var div = this.from.parseTree.createElement('div');
div.innerHTML = this.to.text;
while (div.firstChild) {
this.endNode.parentNode.insertBefore(div.firstChild, this.endNode);
}
} else {
//
this.node.nodeValue = '[if ' + this.condition + ']>' + this.to.text + '';
} else {
this.node.nodeValue = '[if ' + this.condition + ']>
|