From 7c2248933ab196ce12445e6fe47f6d71ca9190ee Mon Sep 17 00:00:00 2001 From: eight Date: Sun, 15 Oct 2017 02:59:55 +0800 Subject: [PATCH] Change: let makeLink accept object --- js/dom.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/js/dom.js b/js/dom.js index 8638e941..f2d6ac49 100644 --- a/js/dom.js +++ b/js/dom.js @@ -195,11 +195,16 @@ function $element(opt) { function makeLink(href = '', content) { - return $element({ + const opt = { tag: 'a', target: '_blank', - href, - rel: 'noopener', - appendChild: content, - }); + rel: 'noopener' + }; + if (typeof href === 'object') { + Object.assign(opt, href); + } else { + opt.href = href; + opt.appendChild = content; + } + return $element(opt); }