Skip to content

Commit

Permalink
Fix broken Node#parent
Browse files Browse the repository at this point in the history
  • Loading branch information
ai committed Oct 16, 2018
1 parent 57ab747 commit 1ec9169
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/hacks/grid-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,8 @@ function insertAreas (css, isDisabled) {
.filter(p => p !== 'lastRule')
.forEach(params => {
if (data[params].length > 0 && lastRule) {
lastRule.after({ name: 'media', nodes: data[params], params })
lastRule.after({ name: 'media', params })
lastRule.next().append(data[params])
}
})
})
Expand Down
14 changes: 14 additions & 0 deletions test/autoprefixer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,20 @@ it('prevents doubling prefixes', () => {
}
})

it('does not broke AST', () => {
function checkParent (node) {
node.walk(child => {
expect(child.parent).toBeDefined()
if (child.nodes) checkParent(child)
})
}
for (let type of COMMONS) {
let processor = postcss([prefixer(type)])
let input = read(type)
checkParent(processor.process(input).root)
}
})

it('parses difficult files', () => {
let input = read('syntax')
let result = postcss([cleaner]).process(input)
Expand Down

0 comments on commit 1ec9169

Please sign in to comment.