Comments (5)
The underlying issue here is that the way minimize outputs the processed HTML again. Hopefully htmlparser2 shows if an element is self closing, otherwise this is a hard fix
Not closing a tag based on the premise of an element not being regular HTML is not possible as that would create ambiguous output.
from minimize.
Just checked it, there is no flag on the parsed elements that indicates whether an element is inline or not. You could try to open an issue at https://github.com/fb55/htmlparser2, but frankly I think this is beyond the scope of both projects. As the aim is to parse/minify HTML and not custom elements implemented by a higher level module/library.
A possible solution would be to create a custom angular parser that is derived from the https://github.com/fb55/domhandler, as that is what htmlparser2 (and thus minimize) use by default. It wouldn't mind to build in optional support for custom handlers and special flags. I do not however have the time to write a custom angular parser (haven't checked if that exists already) myself, so community input would be welcome here.
from minimize.
This is not only an issue for custom tags, but some official HTML tags are also "self closing" (see https://developer.mozilla.org/en-US/docs/Glossary/empty_element)
from minimize.
@jlas as far as I'm aware these are correctly parsed and outputted (code reference), this issue was specifically about custom elements that are not part of the inline list. However, if you have encountered a specific problem I'd like to known.
Also since this issue got revisited, this could potential be solved with a custom plugin, since minimize supports plugins now.
from minimize.
@Swaagie here is an example I was having trouble with:
var M = require('minimize');
var snippet = ('<button><input type="hidden"/></button>');
m = new M();
m.parse(snippet, function (err, data) { console.log(data); });
This outputs:
<button></button><input type=hidden>
Now, as far as I know, <button>
should allow <input>
as a child element, according to MDN. But it seems like htmlparser2 is not allowing that (I think here)...
Anyway I created a PR (#43) which allows passing options to htmlparser2. In my case passing the xmlMode: true
option gets my example above to work. Either way feel free to reject it as I have found another fix, which is to enclose the <input>
in a <div>
instead of <button>
...
from minimize.
Related Issues (20)
- An in-range update of cli-color is breaking the build 🚨 HOT 1
- An in-range update of uuid is breaking the build 🚨 HOT 1
- HTML Attribute Contenteditable Removed By Minimize
- HTML minification eats up spaces between inline elements HOT 3
- Maximum call stack size exceeded HOT 1
- Empty attributes are assigned blank values HOT 4
- This is beyond the scope of this project. NO, IT'S NOT HOT 3
- Django templates error HOT 8
- html tags are autoclosed within a single html file HOT 2
- Keep case HOT 1
- Empty space in attribute HOT 1
- Stripping off extra HTML tags HOT 4
- Minify inline JS - Package link broken? HOT 7
- minifying all HTML files recursively in folder HOT 1
- SSI only supports #includes
- Attribut draggable is no redundant attribute HOT 1
- Feat: remove development code
- Track elements are not considered void elements
- Version 10 of node.js has been released
- An in-range update of htmlparser2 is breaking the build 🚨 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from minimize.