Commit 96d18066 authored by Guido van Rossum's avatar Guido van Rossum

Balk at z:replace and z:repeat on the documentElement.

parent d5580aff
...@@ -127,6 +127,7 @@ class DummyCompiler: ...@@ -127,6 +127,7 @@ class DummyCompiler:
class METALCompiler(DOMVisitor): class METALCompiler(DOMVisitor):
def __init__(self, document, expressionCompiler=None): def __init__(self, document, expressionCompiler=None):
self.document = document
DOMVisitor.__init__(self, document) DOMVisitor.__init__(self, document)
if not expressionCompiler: if not expressionCompiler:
expressionCompiler = DummyCompiler() expressionCompiler = DummyCompiler()
...@@ -378,10 +379,12 @@ class TALCompiler(METALCompiler): ...@@ -378,10 +379,12 @@ class TALCompiler(METALCompiler):
if insert: if insert:
ok = self.doInsert(node, insert) ok = self.doInsert(node, insert)
if not ok and replace: if not ok and replace:
# XXX Check that this isn't the documentElement if node.isSameNode(self.document.documentElement):
raise TALError("can't use replace on the document element")
ok = self.doReplace(node, replace) ok = self.doReplace(node, replace)
if not ok and repeat: if not ok and repeat:
# XXX Check that this isn't the documentElement if node.isSameNode(self.document.documentElement):
raise TALError("can't use repeat on the document element")
ok = self.doRepeat(node, repeat) ok = self.doRepeat(node, repeat)
if not ok: if not ok:
self.emitElement(node) self.emitElement(node)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment