Change: let makeLink accept object
This commit is contained in:
		
							parent
							
								
									a1ca416ef2
								
							
						
					
					
						commit
						7c2248933a
					
				
							
								
								
									
										15
									
								
								js/dom.js
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								js/dom.js
									
									
									
									
									
								
							| 
						 | 
					@ -195,11 +195,16 @@ function $element(opt) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function makeLink(href = '', content) {
 | 
					function makeLink(href = '', content) {
 | 
				
			||||||
  return $element({
 | 
					  const opt = {
 | 
				
			||||||
    tag: 'a',
 | 
					    tag: 'a',
 | 
				
			||||||
    target: '_blank',
 | 
					    target: '_blank',
 | 
				
			||||||
    href,
 | 
					    rel: 'noopener'
 | 
				
			||||||
    rel: 'noopener',
 | 
					  };
 | 
				
			||||||
    appendChild: content,
 | 
					  if (typeof href === 'object') {
 | 
				
			||||||
  });
 | 
					    Object.assign(opt, href);
 | 
				
			||||||
 | 
					  } else {
 | 
				
			||||||
 | 
					    opt.href = href;
 | 
				
			||||||
 | 
					    opt.appendChild = content;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  return $element(opt);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user