Skip to content

Instantly share code, notes, and snippets.

@dutchcelt
Last active February 11, 2024 20:33
Show Gist options
  • Select an option

  • Save dutchcelt/1abd49a692a8832a84f2fd42ed18c250 to your computer and use it in GitHub Desktop.

Select an option

Save dutchcelt/1abd49a692a8832a84f2fd42ed18c250 to your computer and use it in GitHub Desktop.

Revisions

  1. dutchcelt revised this gist Aug 31, 2022. 1 changed file with 10 additions and 7 deletions.
    17 changes: 10 additions & 7 deletions createElement-shortcut.js
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,6 @@
    /* This πŸ‘‡ */
    /* https://twitter.com/jh3yy/status/1564926775620243456
    * This πŸ‘‡ */

    const ELEMENT = Object.assign(
    document.createElement('button'),
    {
    @@ -11,9 +13,10 @@ const ELEMENT = Object.assign(
    }
    )

    /* Instead of this πŸ‘‡ */
    const ELEMENT = document.createElement('button')
    ELEMENT.className = 'fab'
    ELEMENT.setAttribute('popup', 'auto')
    ELEMENT.style = "--index: 1;"
    ELEMENT.innerHTML = '<i class="material-icons">add</i>
    /* Instead of this πŸ‘‡
    const ELEMENT = document.createElement('button')
    ELEMENT.className = 'fab'
    ELEMENT.setAttribute('popup', 'auto')
    ELEMENT.style = "--index: 1;"
    ELEMENT.innerHTML = '<i class="material-icons">add</i>
    */
  2. dutchcelt revised this gist Aug 31, 2022. No changes.
  3. dutchcelt created this gist Aug 31, 2022.
    19 changes: 19 additions & 0 deletions createElement-shortcut.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    /* This πŸ‘‡ */
    const ELEMENT = Object.assign(
    document.createElement('button'),
    {
    className: 'fab',
    popUp: 'manual',
    style: '--index: 1;',
    innerHTML: `
    <i class="material-icons">add</i>
    `
    }
    )

    /* Instead of this πŸ‘‡ */
    const ELEMENT = document.createElement('button')
    ELEMENT.className = 'fab'
    ELEMENT.setAttribute('popup', 'auto')
    ELEMENT.style = "--index: 1;"
    ELEMENT.innerHTML = '<i class="material-icons">add</i>