Skip to content

Commit

Permalink
Fix #40, bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
inikulin committed Feb 3, 2015
1 parent 9bf5f2a commit 2512565
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 17 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 1.3.2
* Fix: `<form>` processing in `<template>` (GH [#40](https://github.com/inikulin/parse5/issues/40))

## 1.3.1
* Fix: text node in `<template>` serialization problem with custom tree adapter (GH [#38](https://github.com/inikulin/parse5/issues/38))

Expand Down
7 changes: 6 additions & 1 deletion lib/tree_construction/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -1814,7 +1814,12 @@ function formEndTagInBody(p, token) {

if ((formElement || inTemplate) && p.openElements.hasInScope($.FORM)) {
p.openElements.generateImpliedEndTags();
p.openElements.remove(formElement);

if (inTemplate)
p.openElements.popUntilTagNamePopped($.FORM);

else
p.openElements.remove(formElement);
}
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "parse5",
"description": "WHATWG HTML5 specification-compliant, fast and ready for production HTML parsing/serialization toolset for Node.",
"version": "1.3.1",
"version": "1.3.2",
"author": "Ivan Nikulin <ifaaan@gmail.com> (https://github.com/inikulin)",
"contributors": [
"Sebastian Mayr <sebmaster16@gmail.com> (http://blog.smayr.name)",
Expand Down
19 changes: 17 additions & 2 deletions test/fixtures/parser_test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,25 @@
var assert = require('assert'),
path = require('path'),
HTML = require('../../lib/common/html'),
Parser = require('../../index').Parser,
TestUtils = require('../test_utils');
parse5 = require('../../index'),
TestUtils = require('../test_utils'),
Parser = parse5.Parser,
Serializer = parse5.Serializer;

TestUtils.generateTestsForEachTreeAdapter(module.exports, function (_test, adapterName, treeAdapter) {

_test['Regression - <form> in <template> (GH-40)'] = function () {
var parser = new Parser(treeAdapter),
serializer = new Serializer(treeAdapter),
src = '<template><form><input name="q"></form><div>second</div></template>',
fragment = parser.parseFragment(src),
actual = serializer.serialize(fragment);

assert.strictEqual(actual, src, TestUtils.getStringDiffMsg(actual, src));
};

//html5lib test suite
//------------------------------------------------------------------------------
function getFullTestName(test) {
return ['Parser - ', test.idx, '.', test.setName, ' - ', test.input].join('');
}
Expand Down
26 changes: 13 additions & 13 deletions test/fixtures/serializer_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,17 @@ exports['Regression - SYSTEM-only doctype serialization'] = function () {

exports['Regression - Escaping of doctypes with quotes in them'] = function () {
var htmlStrs = [
'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ' +
'"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' +
'<html><head></head><body></body></html>',
'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ' +
'"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' +
'<html><head></head><body></body></html>',

'<!DOCTYPE html PUBLIC \'-//W3C//"DTD" XHTML 1.0 Transitional//EN\' ' +
'"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' +
'<html><head></head><body></body></html>',
'<!DOCTYPE html PUBLIC \'-//W3C//"DTD" XHTML 1.0 Transitional//EN\' ' +
'"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' +
'<html><head></head><body></body></html>',

'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ' +
'\'http://www.w3.org/TR/xhtml1/DTD/"xhtml1-transitional.dtd"\'>' +
'<html><head></head><body></body></html>'
'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ' +
'\'http://www.w3.org/TR/xhtml1/DTD/"xhtml1-transitional.dtd"\'>' +
'<html><head></head><body></body></html>'
],
parser = new Parser(),
serializer = new Serializer();
Expand Down Expand Up @@ -93,24 +93,24 @@ exports['Regression - new line in <pre> tag'] = function () {
exports['Options - encodeHtmlEntities'] = function () {
var testHtmlCases = [
{
options: { encodeHtmlEntities: true },
options: {encodeHtmlEntities: true},
src: '<!DOCTYPE html><html><head></head><body>&</body></html>',
expected: '<!DOCTYPE html><html><head></head><body>&amp;</body></html>'
},

{
options: { encodeHtmlEntities: false },
options: {encodeHtmlEntities: false},
src: '<!DOCTYPE html><html><head></head><body>&</body></html>',
expected: '<!DOCTYPE html><html><head></head><body>&</body></html>'
},
{
options: { encodeHtmlEntities: true },
options: {encodeHtmlEntities: true},
src: '<!DOCTYPE html><html><head></head><body><a href="http://example.com?hello=1&world=2"></a></body></html>',
expected: '<!DOCTYPE html><html><head></head><body><a href="http://example.com?hello=1&amp;world=2"></a></body></html>'
},

{
options: { encodeHtmlEntities: false },
options: {encodeHtmlEntities: false},
src: '<!DOCTYPE html><html><head></head><body><a href="http://example.com?hello=1&world=2"></a></body></html>',
expected: '<!DOCTYPE html><html><head></head><body><a href="http://example.com?hello=1&world=2"></a></body></html>'
}
Expand Down

0 comments on commit 2512565

Please sign in to comment.