Commit 3ba25e76 authored by Andrew Balholm's avatar Andrew Balholm Committed by Nigel Tao

exp/html: generate replacement for <isindex> correctly

When generating replacement elements for an <isindex> tag, the old
addSyntheticElement method was producing the wrong nesting. Replace
it with parseImpliedToken.

Pass the one remaining test in the test suite.

R=nigeltao
CC=golang-dev
https://golang.org/cl/6453114
parent 6d5eb61a
...@@ -19,9 +19,8 @@ type parser struct { ...@@ -19,9 +19,8 @@ type parser struct {
tokenizer *Tokenizer tokenizer *Tokenizer
// tok is the most recently read token. // tok is the most recently read token.
tok Token tok Token
// Self-closing tags like <hr/> are re-interpreted as a two-token sequence: // Self-closing tags like <hr/> are treated as start tags, except that
// <hr> followed by </hr>. hasSelfClosingToken is true if we have just read // hasSelfClosingToken is set while they are being processed.
// the synthetic start tag and the next one due is the matching end tag.
hasSelfClosingToken bool hasSelfClosingToken bool
// doc is the document root element. // doc is the document root element.
doc *Node doc *Node
...@@ -313,16 +312,6 @@ func (p *parser) addElement() { ...@@ -313,16 +312,6 @@ func (p *parser) addElement() {
}) })
} }
// addSyntheticElement adds a child element with the given tag and attributes.
func (p *parser) addSyntheticElement(tagAtom a.Atom, attr []Attribute) {
p.addChild(&Node{
Type: ElementNode,
DataAtom: tagAtom,
Data: tagAtom.String(),
Attr: attr,
})
}
// Section 12.2.3.3. // Section 12.2.3.3.
func (p *parser) addFormattingElement() { func (p *parser) addFormattingElement() {
tagAtom, attr := p.tok.DataAtom, p.tok.Attr tagAtom, attr := p.tok.DataAtom, p.tok.Attr
...@@ -935,22 +924,23 @@ func inBodyIM(p *parser) bool { ...@@ -935,22 +924,23 @@ func inBodyIM(p *parser) bool {
} }
p.acknowledgeSelfClosingTag() p.acknowledgeSelfClosingTag()
p.popUntil(buttonScope, a.P) p.popUntil(buttonScope, a.P)
p.addSyntheticElement(a.Form, nil) p.parseImpliedToken(StartTagToken, a.Form, a.Form.String())
p.form = p.top()
if action != "" { if action != "" {
p.form.Attr = []Attribute{{Key: "action", Val: action}} p.form.Attr = []Attribute{{Key: "action", Val: action}}
} }
p.addSyntheticElement(a.Hr, nil) p.parseImpliedToken(StartTagToken, a.Hr, a.Hr.String())
p.oe.pop() p.parseImpliedToken(StartTagToken, a.Label, a.Label.String())
p.addSyntheticElement(a.Label, nil)
p.addText(prompt) p.addText(prompt)
p.addSyntheticElement(a.Input, attr) p.addChild(&Node{
p.oe.pop() Type: ElementNode,
p.oe.pop() DataAtom: a.Input,
p.addSyntheticElement(a.Hr, nil) Data: a.Input.String(),
p.oe.pop() Attr: attr,
})
p.oe.pop() p.oe.pop()
p.form = nil p.parseImpliedToken(EndTagToken, a.Label, a.Label.String())
p.parseImpliedToken(StartTagToken, a.Hr, a.Hr.String())
p.parseImpliedToken(EndTagToken, a.Form, a.Form.String())
case a.Textarea: case a.Textarea:
p.addElement() p.addElement()
p.setOriginalIM() p.setOriginalIM()
...@@ -1036,7 +1026,7 @@ func inBodyIM(p *parser) bool { ...@@ -1036,7 +1026,7 @@ func inBodyIM(p *parser) bool {
p.oe.remove(node) p.oe.remove(node)
case a.P: case a.P:
if !p.elementInScope(buttonScope, a.P) { if !p.elementInScope(buttonScope, a.P) {
p.addSyntheticElement(a.P, nil) p.parseImpliedToken(StartTagToken, a.P, a.P.String())
} }
p.popUntil(buttonScope, a.P) p.popUntil(buttonScope, a.P)
case a.Li: case a.Li:
......
...@@ -9,5 +9,5 @@ PASS "<table><thead><td></tbody>A" ...@@ -9,5 +9,5 @@ PASS "<table><thead><td></tbody>A"
PASS "<legend>test</legend>" PASS "<legend>test</legend>"
PASS "<table><input>" PASS "<table><input>"
PASS "<b><em><dcell><postfield><postfield><postfield><postfield><missing_glyph><missing_glyph><missing_glyph><missing_glyph><hkern><aside></b></em>" PASS "<b><em><dcell><postfield><postfield><postfield><postfield><missing_glyph><missing_glyph><missing_glyph><missing_glyph><hkern><aside></b></em>"
FAIL "<isindex action=\"x\">" PASS "<isindex action=\"x\">"
PASS "<option><XH<optgroup></optgroup>" PASS "<option><XH<optgroup></optgroup>"
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