Andarist / Andarist/stylis-plugin-extra-scope

why first selector was modified?

Đang mở
#16 2 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
JavaScript
Star
23
Fork
14
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

Work with styled-component v5, and I found that first selector will be modified, and this made the whole page's style broken.

image

Here is my test code

```js
export function addCssScope(scopes: string[]) {
// FORM:
// https://github.com/Andarist/stylis-plugin-extra-scope/blob/master/src/index.js
const extraScopePlugin: StylisPlugin = (context, content, selectors) => {
if (context === -2) {
console.log('[selectors]', selectors);
console.log('[content] ', content);
console.log('\n\n');
return;
}

if (context !== -1) {
return;
}

console.log('[before] selectors', selectors);

const selector = selectors[0];
selectors[0] = `.${scopes[0]} ${selector}`;

for (let i = 1; i < scopes.length; i++) {
selectors.push(`.${scopes[i]} ${selector}`);
}

console.log('[after] selectors', selectors);
};

Object.defineProperty(extraScopePlugin, 'name', {
value: 'addCssScopePlugin',
});

return extraScopePlugin;
}

// .......

```

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.