thegooglecodearchive / minify

Automatically exported from code.google.com/p/minify
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Minify_HTML breaks DOM interpretation with attributes. #237

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
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

GoogleCodeExporter commented 9 years ago
Can you give an example of markup it breaks?

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

GoogleCodeExporter commented 9 years ago
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

GoogleCodeExporter commented 9 years ago
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

GoogleCodeExporter commented 9 years ago
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

GoogleCodeExporter commented 9 years ago
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

GoogleCodeExporter commented 9 years ago

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