Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Don't automatically self-close empty tags.

Empty tags shouldn't automatically self-close, or browsers get confused.
The following haml should create a document which, after the script runs,
contains two divs with text. In Firefox, the second div gets erased.

%html
  %body
    %div#a
    %div I do not self close.
    :javascript
      (function(){document.getElementById('a').textContent='I self close';})();
  • Loading branch information...
commit c3de2b97143c9eccbe3b257ff0c85cba61581d99 1 parent 60e9680
@aeosynth aeosynth authored
Showing with 2 additions and 3 deletions.
  1. +2 −3 lib/haml.js
View
5 lib/haml.js
@@ -7,7 +7,7 @@ if (exports) {
(function () {
- var matchers, self_close_tags, no_self_close_tags;
+ var matchers, self_close_tags;
function html_escape(text) {
if (typeof text !== 'string') {
@@ -127,7 +127,6 @@ if (exports) {
}
self_close_tags = ["meta", "img", "link", "br", "hr"];
- no_self_close_tags = ["script"];
// All matchers' regexps should capture leading whitespace in first capture
// and trailing content in last capture
@@ -188,7 +187,7 @@ if (exports) {
content = '';
}
- if ((content.length > 0 && self_close_tags.indexOf(tag) < 0) || no_self_close_tags.indexOf(tag) >= 0 ) {
+ if (self_close_tags.indexOf(tag) == -1) {
return '"<' + tag + attribs + '>"' +
(content.length > 0 ? ' + \n' + content : "") +
' + \n"</' + tag + '>"';

0 comments on commit c3de2b9

Please sign in to comment.
Something went wrong with that request. Please try again.