Changes all references to type === Element in isDomNode()

pull/2203/head
Térence 7 years ago
parent 9bfbbae666
commit 9f9e3d53fa

@ -21,7 +21,7 @@ export default class AttributeWrapper {
// special case — <option value={foo}> — see below
if (this.parent.node.name === 'option' && node.name === 'value') {
let select: ElementWrapper = this.parent;
while (select && (select.node.type !== 'Element' || select.node.name !== 'select')) select = select.parent;
while (select && (select.node.isDomNode() || select.node.name !== 'select')) select = select.parent;
if (select && select.selectBindingDependencies) {
select.selectBindingDependencies.forEach(prop => {

@ -21,9 +21,8 @@ export default class RawMustacheTagWrapper extends Tag {
render(block: Block, parentNode: string, parentNodes: string) {
const name = this.var;
// TODO use isDomNode instead of type === 'Element'?
const needsAnchorBefore = this.prev ? this.prev.node.type !== 'Element' : !parentNode;
const needsAnchorAfter = this.next ? this.next.node.type !== 'Element' : !parentNode;
const needsAnchorBefore = this.prev ? this.prev.isDomNode() : !parentNode;
const needsAnchorAfter = this.next ? this.next.isDomNode() : !parentNode;
const anchorBefore = needsAnchorBefore
? block.getUniqueName(`${name}_before`)
@ -100,4 +99,4 @@ export default class RawMustacheTagWrapper extends Tag {
addAnchorAfter();
}
}
}
}

@ -4,11 +4,11 @@ export default function(node, renderer, options) {
let text = node.data;
if (
!node.parent ||
node.parent.type !== 'Element' ||
node.parent.isDomNode() ||
(node.parent.name !== 'script' && node.parent.name !== 'style')
) {
// unless this Text node is inside a <script> or <style> element, escape &,<,>
text = escapeHTML(text);
}
renderer.append(escape(escapeTemplate(text)));
}
}

@ -157,7 +157,7 @@ export default function tag(parser: Parser) {
// close any elements that don't have their own closing tags, e.g. <div><p></div>
while (parent.name !== name) {
if (parent.type !== 'Element')
if (parent.isDomNode())
parser.error({
code: `invalid-closing-tag`,
message: `</${name}> attempted to close an element that was not open`

Loading…
Cancel
Save