Last active
March 20, 2019 14:40
-
-
Save patrickmj/21ee64921df037d688dee25f944936f6 to your computer and use it in GitHub Desktop.
Trying to figure out the difference in JS between these ways of doing WP Gutenberg blocks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// I've seen code for building WP blocks with JS like this | |
( function( blocks, editor, i18n, element) { | |
var el = element.createElement; | |
var __ = i18n.__; | |
var RichText = editor.RichText; | |
// do block things | |
}( | |
window.wp.blocks, | |
window.wp.editor, | |
window.wp.i18n, | |
window.wp.element | |
) ); | |
// and like this | |
( function() { | |
const blocks = window.wp.blocks; | |
const editor = window.wp.editor; | |
const i18n = window.wp.i18n; | |
const el = window.wp.element.createElement; | |
const RichText = editor.RichText; | |
// do block things | |
}( | |
) ); | |
//just a difference of how the same objects are passed, or is there a scope subtlety I'm missing? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment