Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Term element in content value gets parsed #1414

Merged
merged 2 commits into from Jul 12, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/processor.js
Expand Up @@ -497,6 +497,9 @@ class Processor {
return true
}
}
if (node.type === 'decl' && node.prop === 'content') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (node.type === 'decl' && node.prop === 'content') {
if (node.prop === 'content') {

Only Declaration has prop.

return true
}

return this.disabled(node, result)
}
Expand Down
14 changes: 14 additions & 0 deletions test/autoprefixer.test.ts
Expand Up @@ -86,6 +86,15 @@ let clipper = autoprefixer({
let example = autoprefixer({
overrideBrowserslist: ['defaults']
})
let content = autoprefixer({
overrideBrowserslist: [
'> 2%',
'last 2 years',
'ie 11',
'not ie_mob > 0',
'not dead'
]
})

function prefixer(name: string): Plugin {
if (
Expand Down Expand Up @@ -162,6 +171,8 @@ function prefixer(name: string): Plugin {
return supporter
} else if (name === 'transition-spec') {
return transitionSpec
} else if (name === 'content') {
return content
} else {
return compiler
}
Expand Down Expand Up @@ -370,6 +381,9 @@ it('transition on vendor specific rule', () => {
it('ignore prefix in vendor at rules', () => {
check('at-rules')
})
it('ignore content property', () => {
check('content')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
check('content')
let input = read('content')
let result = postcss([prefixer('scope')]).process(input)
expect(result.css).toEqual(input)

It will allow to avoid the same content in both files.

})

it('uses control comments to whole scope', () => {
let input = read('scope')
Expand Down
3 changes: 3 additions & 0 deletions test/cases/content.css
@@ -0,0 +1,3 @@
a {
content: "Element 'div' not allowed as child of element 'span' in this context.";
}
3 changes: 3 additions & 0 deletions test/cases/content.out.css
@@ -0,0 +1,3 @@
a {
content: "Element 'div' not allowed as child of element 'span' in this context.";
}