From 5086f5a9d90ec6616f05e27d19857d644e15655a Mon Sep 17 00:00:00 2001 From: Dwayne Roberts Date: Fri, 30 Jun 2017 15:11:39 +0200 Subject: [PATCH] Added check for instanceof OrderedElement --- src/inject.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/inject.js b/src/inject.js index 9d17595..c66b68d 100644 --- a/src/inject.js +++ b/src/inject.js @@ -64,8 +64,21 @@ const stringHandlers = { if (Array.isArray(val)) { return val.map(fontFamily).join(","); } else if (typeof val === "object") { - injectStyleOnce(val.src, "@font-face", [val], false); - return `"${val.fontFamily}"`; + let key = val.src; + let fontFamily = val.fontFamily; + + // More than likely this object will be an OrderedElement type + // which will require usage of its getters methods + if (val instanceof OrderedElements) { + // We need to generate a unique key by which we can identify + // this declaration in the the 'alreadyInjected' object + key = `fontface_${hashObject(val)}`; + fontFamily = val.get('fontFamily'); + } + + injectStyleOnce(key, "@font-face", [val], false); + + return `"${fontFamily}"`; } else { return val; }