Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/__tests__/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,13 @@ test('extraneous non-combinating whitespace', ' [href] , [class] ', (t, tr
t.deepEqual(tree.nodes[1].nodes[0].spaces.after, ' ');
});

test('newline in attribute selector', '[class="woop \\\nwoop woop"]', (t, tree) => {
t.deepEqual(tree.nodes[0].nodes[0].attribute, 'class');
t.deepEqual(tree.nodes[0].nodes[0].operator, '=');
t.deepEqual(tree.nodes[0].nodes[0].value, 'woop \nwoop woop');
t.true(tree.nodes[0].nodes[0].quoted);
});
Copy link
Collaborator

@alexander-akait alexander-akait May 10, 2021

Choose a reason for hiding this comment

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

Let's add other popular example:

// http://jsfiddle.net/BoltClock/AHuvh/6
a[href="\a  http://google.com"] {
}

Just avoid future regressions. Anyway good job!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately this example fails at the moment. It turns into \a into a (removes only the \). It seems a different problem though.


test('comments within attribute selectors', '[href/* wow */=/* wow */test]', (t, tree) => {
t.deepEqual(tree.nodes[0].nodes[0].attribute, 'href');
t.deepEqual(tree.nodes[0].nodes[0].operator, '=');
Expand Down
2 changes: 1 addition & 1 deletion src/selectors/attribute.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {ATTRIBUTE} from './types';

const deprecate = require("util-deprecate");

const WRAPPED_IN_QUOTES = /^('|")(.*)\1$/;
const WRAPPED_IN_QUOTES = /^('|")([^]*)\1$/;

const warnOfDeprecatedValueAssignment = deprecate(() => {},
"Assigning an attribute a value containing characters that might need to be escaped is deprecated. " +
Expand Down