diff --git a/htmlparser.js b/htmlparser.js
index c4ee3a7..e051e9a 100644
--- a/htmlparser.js
+++ b/htmlparser.js
@@ -278,7 +278,7 @@ HTMLElement.prototype.stringifycache = function() {
var tmp = [];
for (var key in self.cache.css)
- tmp.push(key + ':' + self.cache.css[key]);
+ self.cache.css[key] && tmp.push(key + ':' + self.cache.css[key]);
if (tmp.length)
self.attrs.style = tmp.join(';');
@@ -353,7 +353,7 @@ HTMLElement.prototype.css = function(key, value) {
var self = this;
self.parsecache();
if (typeof(key) === 'object') {
- for (var k of key) {
+ for (var k of Object.keys(key)) {
value = key[k];
if (value)
self.cache.css[k] = value;
@@ -647,4 +647,4 @@ function parseHTML(html, trim, onerror) {
return dom;
}
-exports.parseHTML = parseHTML;
\ No newline at end of file
+exports.parseHTML = parseHTML;