kemayo / maphilight

jQuery plugin that adds highlighting to image maps
http://davidlynch.org/projects/maphilight/docs/
MIT License
491 stars 278 forks source link

Errors when shape attribute is omitted #88

Closed dwighthouse closed 5 years ago

dwighthouse commented 5 years ago

maphilight makes the assumption that the map area tags will always have a shape attribute.

However, according to the HTML spec, the shape attribute may be omitted. When this occurs, the shape attribute should be assumed to be the rect value.

The attribute may be omitted. The missing value default is the rectangle state.

If this attribute is omitted (as with the removeRedundantAttributes option of html-minifier), the library fails to initialize and will produce an error on hover:

Uncaught TypeError: Cannot read property 'toLowerCase' of null

maphilight should detect this case and default to a rect value if the shape attribute is not in the element.


Additionally, there is a fourth "shape" that the shape attribute can describe: the confusingly named default (which is not the default value when the shape attribute is omitted). It specifies that the entire map area is a hot-spot region, and such an area tag would not have coords attribute (in fact it MUST not, according to the spec).

maphilight incorrectly assumes that both a coords attribute must exist on an area tag, and that the shape of the area cannot be default.