File tree Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Original file line number Diff line number Diff line change 1- /* GitHub userscript utilities v0.2.0
2- * Copyright © 2021 Rob Garrison
1+ /* GitHub userscript utilities v0.2.1
2+ * Copyright © 2022 Rob Garrison
33 * License: MIT
44 */
55/* exported
@@ -210,8 +210,9 @@ const debounce = (fxn, time = 500) => {
210210 make({ el: 'li', text: 'item #2' })
211211 ]);
212212 */
213- const make = ( obj , children ) => {
213+ const make = ( obj = { } , children ) => {
214214 const el = document . createElement ( obj . el || "div" ) ;
215+ const { appendTo } = obj ;
215216 const xref = {
216217 className : "className" ,
217218 id : "id" ,
@@ -222,7 +223,7 @@ const make = (obj, children) => {
222223 if ( obj [ key ] ) {
223224 el [ xref [ key ] ] = obj [ key ] ;
224225 }
225- } )
226+ } ) ;
226227 if ( obj . attrs ) {
227228 for ( let key in obj . attrs ) {
228229 if ( obj . attrs . hasOwnProperty ( key ) ) {
@@ -233,8 +234,10 @@ const make = (obj, children) => {
233234 if ( Array . isArray ( children ) && children . length ) {
234235 children . forEach ( child => el . appendChild ( child ) ) ;
235236 }
236- if ( obj . appendTo ) {
237- const wrap = typeof obj . appendTo === "string" ? $ ( el ) : el ;
237+ if ( appendTo ) {
238+ const wrap = typeof appendTo === "string"
239+ ? $ ( appendTo )
240+ : appendTo ;
238241 if ( wrap ) {
239242 wrap . appendChild ( el ) ;
240243 }
You can’t perform that action at this time.
0 commit comments