From f3211a0984908edfa3a5a0739c0c078af1fb56ef Mon Sep 17 00:00:00 2001 From: axel Date: Mon, 1 Dec 2014 18:43:53 -0500 Subject: [PATCH] Added support for browsers where property obj.consturctor.name isn't supported.(IE was in that case) --- m3u.js | 3 ++- m3u/Item.js | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/m3u.js b/m3u.js index ba1ef63..1e170d6 100644 --- a/m3u.js +++ b/m3u.js @@ -32,7 +32,8 @@ M3U.prototype.set = function setProperty(key, value) { }; M3U.prototype.addItem = function addItem(item) { - this.items[item.constructor.name].push(item); + var itemClassName = item.constructor.name || item.getClassName(); + this.items[itemClassName].push(item); return this; }; diff --git a/m3u/Item.js b/m3u/Item.js index 9c4f56e..d19b8a9 100644 --- a/m3u/Item.js +++ b/m3u/Item.js @@ -54,3 +54,7 @@ Item.prototype.setData = function setData(data) { Item.prototype.propertiesHasKey = function hasKey(key) { return Object.keys(this.properties).indexOf(key) > -1; }; + +Item.prototype.getClassName = function getName() { + return this.constructor.toString().match(/function (\w*)/)[1]; +}; \ No newline at end of file