googlearchive / core-input

A single-line text field with some extra powers
7 stars 20 forks source link

Parse error on "?=" #31

Closed yfr closed 10 years ago

yfr commented 10 years ago

Hey,

i use grunt-contrib-htmlmin (which uses https://github.com/kangax/html-minifier) to minify my html after vulcanizing it and get parse errors at places where ?= is used in the html of core-icon element. For example like this one fit?="{{rows === 'fit'}}".

?= is not valid html i guess? What does it do anyway. And how can i get around this error?

Thanks!

arv commented 10 years ago

Actually, foo?="bar" is valid in HTML. It is an attribute with the name foo?.

yfr commented 10 years ago

I never saw this kind of attribute names so i search a little. (could have saved me a lot of time if i did this before) and actually foo?=bar is not valid HTML. For one because every element has a defined set of attributes and as far as i know custom attributes besides data-* are not allowed. And secondly i found some issues in the html-minifier with pointed out the same issues i had: https://github.com/kangax/html-minifier/search?q=polymer&type=Issues&utf8=%E2%9C%93.

In the end this is not a valid HTML attribute naming convention but a polymer specific boolean settings option described here in the official poylmer docs: http://www.polymer-project.org/docs/polymer/binding-types.html#conditional-attributes

jmesserly commented 10 years ago

@yfr -- in cases like these it is best to consult the HTML specification ... see "anything else" section. ? is completely valid in an attribute name (as are many other characters).

yfr commented 10 years ago

@jmersserly thanks for pointing me to the spec. I honestly mostly don't know where to find these things and how to read them.

But anyway i this case it is not a Attribute name but a conditional operator. Which makes a big difference. And if one can close comments in a project, one should know the real purpose oft the element in question.

But thanks i like when i learn stuff. Am 04.09.2014 22:26 schrieb "John Messerly" notifications@github.com:

@yfr https://github.com/yfr -- in cases like these it is best to consult the HTML specification http://www.whatwg.org/specs/web-apps/current-work/multipage/syntax.html#attribute-name-state ... see "anything else" section. ? is completely valid in an attribute name (as are many other characters).

— Reply to this email directly or view it on GitHub https://github.com/Polymer/core-input/issues/31#issuecomment-54539303.

robdodson commented 10 years ago

@yfr have you tried https://github.com/sindresorhus/grunt-minify-html ? I was using htmlmin but found it didn't play very nice with some of the things we do in polymer.

yfr commented 10 years ago

@robdodson Thanks will check that out.

Also i have decided to not include the element templates in the index.html but to have a index-elements.html which i include via link tag. So i have a bundled html-elements file and a pretty normal html page. I use the "normal" html-min for the standard index.html and the vulcanize tool from polymer on the elements files. Vulcanize does the minification also pretty well.

robdodson commented 10 years ago

Yeah that's the same approach we use for the Polymer Yeoman generator On Sep 5, 2014 4:00 AM, "Frank Mecklenburg" notifications@github.com wrote:

@robdodson https://github.com/robdodson Thanks will check that out.

Also i have decided to not include the element templates in the index.html but to have a index-elements.html which i include via link tag. So i have a bundled html-elements file and a pretty normal html page. I use the "normal" html-min for the standard index.html and the vulcanize https://github.com/Polymer/vulcanize tool from polymer on the elements files. Vulcanize does the minification also pretty well.

— Reply to this email directly or view it on GitHub https://github.com/Polymer/core-input/issues/31#issuecomment-54611498.