javascript - what is the purpose of the namespace argument when customizing blocks?

admin2025-06-03  7

I'm trying to customize the Gallery block using the new Gutenberk Block API thing.

Long story short, I need to add a filter to do the customization.

So what is the purpose of the namespace argument when calling the addFilter function? I am failing to find an explanation for the purpose of this argument.

Edit: Essentially, I am trying to do what is shown in this post/question. Still, the question remains, what is the purpose of the namespace argument, and its role in the scope of the project?

Ref: Validation error: Extending Gutenberg gallery block

Also, if you're going to downvote, can you explain why?

I'm trying to customize the Gallery block using the new Gutenberk Block API thing.

Long story short, I need to add a filter to do the customization.

So what is the purpose of the namespace argument when calling the addFilter function? I am failing to find an explanation for the purpose of this argument.

Edit: Essentially, I am trying to do what is shown in this post/question. Still, the question remains, what is the purpose of the namespace argument, and its role in the scope of the project?

Ref: Validation error: Extending Gutenberg gallery block

Also, if you're going to downvote, can you explain why?

Share Improve this question edited Feb 14, 2019 at 18:11 Jeff Wilkerson asked Feb 12, 2019 at 20:02 Jeff WilkersonJeff Wilkerson 3151 gold badge4 silver badges13 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 2

So what is the purpose of the namespace argument when calling the addFilter function? I am failing to find an explanation for the purpose of this argument.

The core ticket for adding Javascript actions and filters is #21170

It spans many years and contains a lot of discussions about e.g. namespacing.

See e.g. this comment by @azaozz:

Also thinking the namespaces/identifiers should be required as that would make removing anonymous functions easy. As far as I see the most common use of this would be with anonymous functions

and then it gets implemented e.g. here by @adamsilverstein and then with more iterations.

Here's another description by Igor Benić:

That difference is the namespace which you also add when adding actions and filters (or removing them). This is done in case you have same function names under different components (or Apps). With using namespaces you can easily distinguish to which component or app it belongs so you don’t accidentaly remove the wrong function.

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1748907027a314709.html

最新回复(0)