From a8e93d3caa5e596761d45f330ee6e611e73d67cd Mon Sep 17 00:00:00 2001 From: Ferit Date: Fri, 9 Oct 2026 23:04:09 +0300 Subject: [PATCH] Fix custom at-rule names inherited from Object.prototype --- index.js | 2 +- index.test.js | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 5e30d71..e2c9b30 100644 --- a/index.js +++ b/index.js @@ -149,7 +149,7 @@ function pickAndClearDeclarations( function atruleNames(defaults, custom = '') { let names = defaults.concat(custom) - let list = {} + let list = Object.create(null) for (let name of names) { list[name.replace(/^@/, '')] = true } diff --git a/index.test.js b/index.test.js index 0ed6ece..b1ad386 100644 --- a/index.test.js +++ b/index.test.js @@ -29,6 +29,17 @@ test('cleans rules after unwrap', () => { run('a { b .one {} b .two {} }', 'a b .one {} a b .two {}') }) +test('does not bubble inherited object property names', () => { + run('a { @constructor { color: red } }', 'a { @constructor { color: red } }') + run('a { @toString { color: red } }', 'a { @toString { color: red } }') +}) + +test('bubbles explicitly configured inherited object property names', () => { + run('a { @constructor { color: red } }', '@constructor { a { color: red } }', { + bubble: ['constructor'] + }) +}) + test('preserve empty rules if preserveEmpty is set to true', () => { run('a { b .one {} b .two {} }', 'a { } a b .one {} a b .two {}', { preserveEmpty: true