closing tag search is case-insensitive
authorDuncan Beevers <duncan@dweebd.com>
Wed, 20 Aug 2014 16:45:28 +0000 (11:45 -0500)
committerDuncan Beevers <duncan@dweebd.com>
Wed, 20 Aug 2014 16:45:28 +0000 (11:45 -0500)
src/htmlparser.js
tests/minifier.js

index cf4dd23..a4447be 100644 (file)
         }
         else if ( html.indexOf('<') === 0 ) {
           match = html.match( startTag );
-
           if ( match ) {
             html = html.substring( match[0].length );
             match[0].replace( startTag, parseStartTag );
       if ( !tagName ) {
         pos = 0;
       }
-      else {      // Find the closest opened tag of the same type
+      else {
+        // Find the closest opened tag of the same type
+        var needle = tagName.toLowerCase();
         for ( pos = stack.length - 1; pos >= 0; pos-- ) {
-          if ( stack[ pos ].toLowerCase() === tagName ) {
+          if ( stack[ pos ].toLowerCase() === needle ) {
             break;
           }
         }
index 7fba30c..72b35f5 100644 (file)
@@ -56,6 +56,9 @@
     equal(minify('<a href>ok</a>'), '<a href>ok</a>');
 
     equal(minify('<a onclick></a>'), '<a onclick></a>');
+
+    // https://github.com/kangax/html-minifier/issues/229
+    equal(minify('<CUSTOM-TAG></CUSTOM-TAG><div>Hello :)</div>'), '<custom-tag></custom-tag><div>Hello :)</div>');
   });
 
   test('`minifiy` exists', function() {