Skip to content

Instantly share code, notes, and snippets.

@patrickmj
Last active March 20, 2019 14:40
Show Gist options
  • Save patrickmj/21ee64921df037d688dee25f944936f6 to your computer and use it in GitHub Desktop.
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
// 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