Skip to content

Fix container.atPosition() API doc #264

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

Merged
merged 1 commit into from
May 20, 2022

Conversation

ybiquitous
Copy link
Contributor

This PR fixes the API doc for container.atPosition(line, column).

I referred to the following code for the description and example:

test('Container#atPosition first pseudo', (t) => {
parse(':not(.foo),\n#foo > :matches(ol, ul)', (root) => {
let node = root.atPosition(1, 1);
t.deepEqual(node.type, "pseudo");
t.deepEqual(node.toString(), ":not(.foo)");
});
});
test('Container#atPosition class in pseudo', (t) => {
parse(':not(.foo),\n#foo > :matches(ol, ul)', (root) => {
let node = root.atPosition(1, 6);
t.deepEqual(node.type, "class");
t.deepEqual(node.toString(), ".foo");
});
});
test('Container#atPosition id in second selector', (t) => {
parse(':not(.foo),\n#foo > :matches(ol, ul)', (root) => {
let node = root.atPosition(2, 1);
t.deepEqual(node.type, "id");
t.deepEqual(node.toString(), "\n#foo");
});
});

/**
* Return the most specific node at the line and column number given.
* The source location is based on the original parsed location, locations aren't
* updated as selector nodes are mutated.
*
* Note that this location is relative to the location of the first character
* of the selector, and not the location of the selector in the overall document
* when used in conjunction with postcss.
*
* If not found, returns undefined.
* @param {number} line The line number of the node to find. (1-based index)
* @param {number} col The column number of the node to find. (1-based index)
*/
atPosition (line, col) {

@alexander-akait alexander-akait merged commit c3db2ff into postcss:master May 20, 2022
@ybiquitous ybiquitous deleted the patch-1 branch May 20, 2022 10:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants