This plugin merges the locals from options.expressions.locals and the locals attribute into the options.expressions.locals property. Arrays in the locals attribute will be copied into options.expressions.locals and when the plugin is called again they will be merged again, doubling all array entries every time the plugin is called.
I added a test which checks if options.expressions.locals stays the same after rendering with the plugin. Run the GitHub Action for the commit test: add test for options.expressions.locals pollution to see the failing test. Run Actions for latest commit for succeeding tests.
This plugin merges the locals from
options.expressions.locals
and thelocals
attribute into theoptions.expressions.locals
property. Arrays in thelocals
attribute will be copied intooptions.expressions.locals
and when the plugin is called again they will be merged again, doubling all array entries every time the plugin is called.https://github.com/posthtml/posthtml-extend/blob/ccf454a4b0ead941626bd7c09aae79c0e8c2388c/src/index.js#L53-L54
I fixed that by copying the
options.expressions
object into a new object.I added a test which checks if
options.expressions.locals
stays the same after rendering with the plugin. Run the GitHub Action for the commit test: add test for options.expressions.locals pollution to see the failing test. Run Actions for latest commit for succeeding tests.