diff --git a/action_text-trix/app/assets/javascripts/trix.js b/action_text-trix/app/assets/javascripts/trix.js index 8d831cd03..9e3d41a7c 100644 --- a/action_text-trix/app/assets/javascripts/trix.js +++ b/action_text-trix/app/assets/javascripts/trix.js @@ -1397,7 +1397,7 @@ $\ const result = []; for (const key in this.values) { const value = this.values[key]; - result.push(result.push(key, value)); + result.push(key, value); } this.array = result.slice(0); } diff --git a/src/test/unit/hash_test.js b/src/test/unit/hash_test.js new file mode 100644 index 000000000..33c7e24cf --- /dev/null +++ b/src/test/unit/hash_test.js @@ -0,0 +1,9 @@ +import { assert, test, testGroup } from "test/test_helper" + +import Hash from "trix/core/collections/hash" + +testGroup("Hash", () => { + test("toArray returns flattened key-value pairs", () => { + assert.deepEqual(new Hash({ a: 1, b: 2 }).toArray(), [ "a", 1, "b", 2 ]) + }) +}) diff --git a/src/trix/core/collections/hash.js b/src/trix/core/collections/hash.js index c5200fdf7..93c7e9082 100644 --- a/src/trix/core/collections/hash.js +++ b/src/trix/core/collections/hash.js @@ -80,7 +80,7 @@ export default class Hash extends TrixObject { const result = [] for (const key in this.values) { const value = this.values[key] - result.push(result.push(key, value)) + result.push(key, value) } this.array = result.slice(0) }