mennake / minify

Automatically exported from code.google.com/p/minify

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Minify_HTML breaks DOM interpretation with attributes.

GoogleCodeExporter opened this issue · comments

Minify_HTML::process

Putting attribute list on new line breaks the DOM interpretation, as the tag 
and attribute name are seen together.

To fix it, I tried adding a space next-to newline.

(file: lib/Minify/HTML.php line: ~139)
$this->_html = preg_replace('/(<[a-z\\-]+)\\s+([^>]+>)/i', "$1\n $2", 
$this->_html);

Original issue reported on code.google.com by prasad8...@gmail.com on 17 Jun 2011 at 11:24

Can you give an example of markup it breaks?

Original comment by mrclay....@gmail.com on 17 Jun 2011 at 4:26

I had following snippet in a template file and was trying to minify and merge 
it on the html page. 

<div class="toolbar"> View:</div>

The output was:
<divclass="toolbar"> View: </div>

Hope it helps.

Original comment by prasad8...@gmail.com on 21 Jun 2011 at 5:07

I can't reproduce this bug. The output I get has a newline between "<div" and 
"class=". Can you give me another example?

Original comment by mrclay....@gmail.com on 23 Jun 2011 at 7:28

Try the following:

<?php

set_include_path(dirname(__FILE__). '/libs/min/lib' . PATH_SEPARATOR . 
get_include_path());
include_once 'Minify/HTML.php';

$input = '<div class="aClass">aContent</div>';

echo Minify_HTML::minify($input);
?>

Output was:
<div
class="aClass">aContent</div>

which firefox 4.x interpreted as <divclass="aClass"... and missed applying the 
style.

Original comment by prasad8...@gmail.com on 24 Jun 2011 at 4:57

It's perfectly valid to use "\n" rather than " " as whitespace in a tag, and 
browsers should have no problem parsing it. FF5/XP and FF4/OSX both do fine for 
me rendering these pages, which are processed by Minify_HTML:

http://mrclay.org/min/builder/
http://fawn.ifas.ufl.edu/mobile/260

Can you create a public demo page so others can verify this is indeed a FF4 
parsing bug and not some kind of authoring error?

Original comment by mrclay....@gmail.com on 24 Jun 2011 at 9:54

  • Changed state: NeedInfo
  • Added labels: Priority-Low
  • Removed labels: Priority-Medium

Original comment by mrclay....@gmail.com on 3 Sep 2011 at 11:11

  • Changed state: Invalid