Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@shwao
Copy link

@shwao shwao commented Dec 6, 2022

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.

options.expressions.locals = merge(options.expressions.locals, locals);
const plugins = [...options.plugins, expressions(options.expressions)];

I fixed that by copying the options.expressions object into a new object.

const plugins = [...options.plugins, expressions({
  ...options.expressions,
  locals: merge(options.expressions.locals, locals)
})];

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.

@Scrum Scrum merged commit d13fefb into posthtml:master Dec 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants