@cypress/unique-selector 0.4.3 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/lib/getData.js +7 -23
  2. package/lib/getName.js +19 -0
  3. package/lib/index.js +34 -56
  4. package/lib/isUnique.js +6 -2
  5. package/package.json +8 -11
  6. package/.babelrc +0 -3
  7. package/.eslintrc +0 -42
  8. package/.history/package-lock_20211116100405.json +0 -7884
  9. package/.history/package-lock_20211116101347.json +0 -7884
  10. package/.history/package_20180226102655.json +0 -62
  11. package/.history/package_20211018091805.json +0 -62
  12. package/.history/package_20211018091928.json +0 -62
  13. package/.history/package_20211116101343.json +0 -62
  14. package/.history/src/getData_20211116100405.js +0 -24
  15. package/.history/src/getData_20211116100500.js +0 -24
  16. package/.history/src/getData_20211116100511.js +0 -24
  17. package/.history/src/getData_20211116100803.js +0 -25
  18. package/.history/src/getData_20211116100925.js +0 -25
  19. package/.history/src/getData_20211116101054.js +0 -25
  20. package/.history/src/getData_20211116101058.js +0 -25
  21. package/.history/src/getData_20211116101234.js +0 -26
  22. package/.history/src/getData_20211116101243.js +0 -28
  23. package/.history/src/getData_20211116101301.js +0 -29
  24. package/.history/test/unique-selector_20180226102601.js +0 -131
  25. package/.history/test/unique-selector_20211018092001.js +0 -131
  26. package/.history/test/unique-selector_20211018092018.js +0 -131
  27. package/.history/test/unique-selector_20211018092209.js +0 -132
  28. package/.history/test/unique-selector_20211018092230.js +0 -132
  29. package/.history/test/unique-selector_20211018092245.js +0 -130
  30. package/.travis.yml +0 -11
  31. package/component.json +0 -12
  32. package/src/getAttributes.js +0 -20
  33. package/src/getClasses.js +0 -38
  34. package/src/getCombinations.js +0 -44
  35. package/src/getData.js +0 -29
  36. package/src/getID.js +0 -17
  37. package/src/getNthChild.js +0 -33
  38. package/src/getParents.js +0 -19
  39. package/src/getTag.js +0 -9
  40. package/src/index.js +0 -197
  41. package/src/isElement.js +0 -17
  42. package/src/isUnique.js +0 -12
  43. package/static/bundle.js +0 -5
  44. package/test/index.html +0 -0
  45. package/test/unique-selector.js +0 -146
@@ -1,62 +0,0 @@
1
- {
2
- "name": "@cypress/unique-selector",
3
- "version": "0.4.1",
4
- "description": "Given a DOM node, return a unique CSS selector matching only that element",
5
- "main": "./lib/index.js",
6
- "jsnext:main": "./src/index.js",
7
- "directories": {
8
- "test": "test"
9
- },
10
- "scripts": {
11
- "build": "npm run compile",
12
- "test": "npm run compile && mocha --ignore-leaks --compilers js:babel-register",
13
- "compile": "babel -d lib/ src/",
14
- "prepublish": "npm run compile",
15
- "watch": "npm-scripts-watcher"
16
- },
17
- "watch": {
18
- "src/**/*.js": [
19
- "compile"
20
- ]
21
- },
22
- "repository": {
23
- "type": "git",
24
- "url": "git://github.com/ericclemmons/unique-selector.git"
25
- },
26
- "keywords": [
27
- "dom",
28
- "html",
29
- "css",
30
- "selector",
31
- "event"
32
- ],
33
- "author": "Eric Clemmons <eric@smarterspam.com>",
34
- "contributors": [
35
- {
36
- "name": "Avraam Mavridis",
37
- "email": "avr.mav@gmail.com"
38
- }
39
- ],
40
- "license": "MIT",
41
- "devDependencies": {
42
- "babel-cli": "^6.1.18",
43
- "babel-core": "^6.1.18",
44
- "babel-preset-latest": "^6.24.1",
45
- "babel-register": "^6.3.13",
46
- "chai": "^3.5.0",
47
- "component": "~0.10.1",
48
- "eslint": "^2.6.0",
49
- "eslint-config-airbnb": "^6.2.0",
50
- "eslint-config-airbnb-lite": "^1.0.4",
51
- "eslint-plugin-react": "^4.2.3",
52
- "jquery": "^2.2.3",
53
- "jsdom": "^8.3.0",
54
- "mocha": "~1.7.4",
55
- "mocha-jsdom": "^1.1.0",
56
- "mocha-phantomjs": "~1.1.1",
57
- "npm-scripts-watcher": "^1.0.2"
58
- },
59
- "dependencies": {
60
- "css.escape": "^1.5.1"
61
- }
62
- }
@@ -1,62 +0,0 @@
1
- {
2
- "name": "@cypress/unique-selector",
3
- "version": "0.4.1",
4
- "description": "Given a DOM node, return a unique CSS selector matching only that element",
5
- "main": "./lib/index.js",
6
- "jsnext:main": "./src/index.js",
7
- "directories": {
8
- "test": "test"
9
- },
10
- "scripts": {
11
- "build": "npm run compile",
12
- "test": "npm run compile && mocha --ignore-leaks --compilers js:babel-register",
13
- "compile": "babel -d lib/ src/",
14
- "prepublish": "npm run compile",
15
- "watch": "npm-scripts-watcher"
16
- },
17
- "watch": {
18
- "src/**/*.js": [
19
- "compile"
20
- ]
21
- },
22
- "repository": {
23
- "type": "git",
24
- "url": "git://github.com/ericclemmons/unique-selector.git"
25
- },
26
- "keywords": [
27
- "dom",
28
- "html",
29
- "css",
30
- "selector",
31
- "event"
32
- ],
33
- "author": "Eric Clemmons <eric@smarterspam.com>",
34
- "contributors": [
35
- {
36
- "name": "Avraam Mavridis",
37
- "email": "avr.mav@gmail.com"
38
- }
39
- ],
40
- "license": "MIT",
41
- "devDependencies": {
42
- "babel-cli": "^6.26.0",
43
- "babel-core": "^6.26.3",
44
- "babel-preset-latest": "^6.24.1",
45
- "babel-register": "^6.26.0",
46
- "chai": "^4.3.4",
47
- "component": "~1.1.0",
48
- "eslint": "^8.0.1",
49
- "eslint-config-airbnb": "^18.2.1",
50
- "eslint-config-airbnb-lite": "^1.0.4",
51
- "eslint-plugin-react": "^7.26.1",
52
- "jquery": "^3.6.0",
53
- "jsdom": "^18.0.0",
54
- "mocha": "~9.1.3",
55
- "mocha-jsdom": "^2.0.0",
56
- "mocha-phantomjs": "~4.1.0",
57
- "npm-scripts-watcher": "^1.0.2"
58
- },
59
- "dependencies": {
60
- "css.escape": "^1.5.1"
61
- }
62
- }
@@ -1,62 +0,0 @@
1
- {
2
- "name": "@cypress/unique-selector",
3
- "version": "0.4.1",
4
- "description": "Given a DOM node, return a unique CSS selector matching only that element",
5
- "main": "./lib/index.js",
6
- "jsnext:main": "./src/index.js",
7
- "directories": {
8
- "test": "test"
9
- },
10
- "scripts": {
11
- "build": "npm run compile",
12
- "test": "npm run compile && mocha --ignore-leaks",
13
- "compile": "babel -d lib/ src/",
14
- "prepublish": "npm run compile",
15
- "watch": "npm-scripts-watcher"
16
- },
17
- "watch": {
18
- "src/**/*.js": [
19
- "compile"
20
- ]
21
- },
22
- "repository": {
23
- "type": "git",
24
- "url": "git://github.com/ericclemmons/unique-selector.git"
25
- },
26
- "keywords": [
27
- "dom",
28
- "html",
29
- "css",
30
- "selector",
31
- "event"
32
- ],
33
- "author": "Eric Clemmons <eric@smarterspam.com>",
34
- "contributors": [
35
- {
36
- "name": "Avraam Mavridis",
37
- "email": "avr.mav@gmail.com"
38
- }
39
- ],
40
- "license": "MIT",
41
- "devDependencies": {
42
- "babel-cli": "^6.26.0",
43
- "babel-core": "^6.26.3",
44
- "babel-preset-latest": "^6.24.1",
45
- "babel-register": "^6.26.0",
46
- "chai": "^4.3.4",
47
- "component": "~1.1.0",
48
- "eslint": "^8.0.1",
49
- "eslint-config-airbnb": "^18.2.1",
50
- "eslint-config-airbnb-lite": "^1.0.4",
51
- "eslint-plugin-react": "^7.26.1",
52
- "jquery": "^3.6.0",
53
- "jsdom": "^18.0.0",
54
- "mocha": "~9.1.3",
55
- "mocha-jsdom": "^2.0.0",
56
- "mocha-phantomjs": "~4.1.0",
57
- "npm-scripts-watcher": "^1.0.2"
58
- },
59
- "dependencies": {
60
- "css.escape": "^1.5.1"
61
- }
62
- }
@@ -1,62 +0,0 @@
1
- {
2
- "name": "@cypress/unique-selector",
3
- "version": "0.4.3",
4
- "description": "Given a DOM node, return a unique CSS selector matching only that element",
5
- "main": "./lib/index.js",
6
- "jsnext:main": "./src/index.js",
7
- "directories": {
8
- "test": "test"
9
- },
10
- "scripts": {
11
- "build": "npm run compile",
12
- "test": "npm run compile && mocha --ignore-leaks",
13
- "compile": "babel -d lib/ src/",
14
- "prepublish": "npm run compile",
15
- "watch": "npm-scripts-watcher"
16
- },
17
- "watch": {
18
- "src/**/*.js": [
19
- "compile"
20
- ]
21
- },
22
- "repository": {
23
- "type": "git",
24
- "url": "git://github.com/ericclemmons/unique-selector.git"
25
- },
26
- "keywords": [
27
- "dom",
28
- "html",
29
- "css",
30
- "selector",
31
- "event"
32
- ],
33
- "author": "Eric Clemmons <eric@smarterspam.com>",
34
- "contributors": [
35
- {
36
- "name": "Avraam Mavridis",
37
- "email": "avr.mav@gmail.com"
38
- }
39
- ],
40
- "license": "MIT",
41
- "devDependencies": {
42
- "babel-cli": "^6.26.0",
43
- "babel-core": "^6.26.3",
44
- "babel-preset-latest": "^6.24.1",
45
- "babel-register": "^6.26.0",
46
- "chai": "^4.3.4",
47
- "component": "~1.1.0",
48
- "eslint": "^8.0.1",
49
- "eslint-config-airbnb": "^18.2.1",
50
- "eslint-config-airbnb-lite": "^1.0.4",
51
- "eslint-plugin-react": "^7.26.1",
52
- "jquery": "^3.6.0",
53
- "jsdom": "^18.0.0",
54
- "mocha": "~9.1.3",
55
- "mocha-jsdom": "^2.0.0",
56
- "mocha-phantomjs": "~4.1.0",
57
- "npm-scripts-watcher": "^1.0.2"
58
- },
59
- "dependencies": {
60
- "css.escape": "^1.5.1"
61
- }
62
- }
@@ -1,24 +0,0 @@
1
- /**
2
- * Returns the data-{dataAttr} selector of the element wrapped in double quotes.
3
- * @param { String } selectorType - The type of selector to return.
4
- * @return { String } - The data-{dataAttr} selector of the element wrapped in double quotes.
5
- */
6
-
7
- export const getData = ( selectorType, attributes ) => {
8
- for ( let i = 0; i < attributes.length; i++ ) {
9
- // extract node name + value
10
- const { nodeName, value } = attributes[ i ];
11
-
12
- // if this matches our selector
13
- if ( nodeName === selectorType ){
14
- if ( value ) {
15
- // if we have value that needs quotes
16
- return `[${nodeName}="${value}"]`;
17
- }
18
-
19
- return `[${nodeName}]`;
20
- }
21
- }
22
-
23
- return null;
24
- };
@@ -1,24 +0,0 @@
1
- /**
2
- * Returns the data-{dataAttr} selector of the element wrapped in double quotes.
3
- * @param { String } selectorType - The type of selector to return.
4
- * @return { String } - The data-{dataAttr} selector of the element wrapped in double quotes.
5
- */
6
-
7
- export const getData = ( selectorType, attributes ) => {
8
- for ( let i = 0; i < attributes.length; i++ ) {
9
- // extract node name + value
10
- const { nodeName, value } = attributes[ i ];
11
-
12
- // if this matches our selector
13
- if ( nodeName === selectorType ){
14
- if ( value ) {
15
- // if we have value that needs quotes
16
- return `[${nodeName}="${value}"]`;
17
- }
18
-
19
- return `[${nodeName}]`;
20
- }
21
- }
22
-
23
- return null;
24
- };
@@ -1,24 +0,0 @@
1
- /**
2
- * Returns the data-{dataAttr} selector of the element wrapped in double quotes.
3
- * @param { String } selectorType - The type of selector to return.
4
- * @return { String } - The data-{dataAttr} selector of the element wrapped in double quotes.
5
- */
6
-
7
- export const getData = ( selectorType, attributes ) => {
8
- for ( let i = 0; i < attributes.length; i++ ) {
9
- // extract node name + value
10
- const { nodeName, value } = attributes[ i ];
11
-
12
- // if this matches our selector
13
- if ( nodeName === selectorType ){
14
- if ( value ) {
15
- // if we have value that needs quotes
16
- return `[${nodeName}="${value}"]`;
17
- }
18
-
19
- return `[${nodeName}]`;
20
- }
21
- }
22
-
23
- return null;
24
- };
@@ -1,25 +0,0 @@
1
- /**
2
- * Returns the data-{dataAttr} selector of the element
3
- * @param { String } selectorType - The type of selector to return.
4
- * @param { String } attributes - The attributes of the element.
5
- * @return { String } - The data-{dataAttr} selector of the element.
6
- */
7
-
8
- export const getData = ( selectorType, attributes ) => {
9
- for ( let i = 0; i < attributes.length; i++ ) {
10
- // extract node name + value
11
- const { nodeName, value } = attributes[ i ];
12
-
13
- // if this matches our selector
14
- if ( nodeName === selectorType ){
15
- if ( value ) {
16
- // if we have value that needs quotes
17
- return `[${nodeName}="${value}"]`;
18
- }
19
-
20
- return `[${nodeName}]`;
21
- }
22
- }
23
-
24
- return null;
25
- };
@@ -1,25 +0,0 @@
1
- /**
2
- * Returns the data-{dataAttr} selector of the element
3
- * @param { String } selectorType - The type of selector to return.
4
- * @param { String } attributes - The attributes of the element.
5
- * @return { String | null } - The data-{dataAttr} selector of the element.
6
- */
7
-
8
- export const getData = ( selectorType, attributes ) => {
9
- for ( let i = 0; i < attributes.length; i++ ) {
10
- // extract node name + value
11
- const { nodeName, value } = attributes[ i ];
12
-
13
- // if this matches our selector
14
- if ( nodeName === selectorType ){
15
- if ( value ) {
16
- // if we have value that needs quotes
17
- return `[${nodeName}="${value}"]`;
18
- }
19
-
20
- return `[${nodeName}]`;
21
- }
22
- }
23
-
24
- return null;
25
- };
@@ -1,25 +0,0 @@
1
- /**
2
- * Returns the data attribute selector of the element
3
- * @param { String } selectorType - The type of selector to return.
4
- * @param { String } attributes - The attributes of the element.
5
- * @return { String | null } - The data attribute selector of the element.
6
- */
7
-
8
- export const getData = ( selectorType, attributes ) => {
9
- for ( let i = 0; i < attributes.length; i++ ) {
10
- // extract node name + value
11
- const { nodeName, value } = attributes[ i ];
12
-
13
- // if this matches our selector
14
- if ( nodeName === selectorType ){
15
- if ( value ) {
16
- // if we have value that needs quotes
17
- return `[${nodeName}="${value}"]`;
18
- }
19
-
20
- return `[${nodeName}]`;
21
- }
22
- }
23
-
24
- return null;
25
- };
@@ -1,25 +0,0 @@
1
- /**
2
- * Returns the data-{dataAttr} selector of the element
3
- * @param { String } selectorType - The type of selector to return.
4
- * @param { String } attributes - The attributes of the element.
5
- * @return { String | null } - The data-{dataAttr} selector of the element.
6
- */
7
-
8
- export const getData = ( selectorType, attributes ) => {
9
- for ( let i = 0; i < attributes.length; i++ ) {
10
- // extract node name + value
11
- const { nodeName, value } = attributes[ i ];
12
-
13
- // if this matches our selector
14
- if ( nodeName === selectorType ){
15
- if ( value ) {
16
- // if we have value that needs quotes
17
- return `[${nodeName}="${value}"]`;
18
- }
19
-
20
- return `[${nodeName}]`;
21
- }
22
- }
23
-
24
- return null;
25
- };
@@ -1,26 +0,0 @@
1
- /**
2
- * Returns the data-{dataAttr} selector of the element
3
- * @param { String } selectorType - The type of selector to return.
4
- * @param { String } attributes - The attributes of the element.
5
- * @return { String | null } - The data-{dataAttr} selector of the element.
6
- */
7
-
8
- export const getData = ( selectorType, attributes ) => {
9
- for ( let i = 0; i < attributes.length; i++ ) {
10
- // extract node name + value
11
- const { nodeName, value } = attributes[ i ];
12
-
13
- // if this matches our selector
14
- if ( nodeName === selectorType )
15
- {
16
- if ( value ) {
17
- // if we have value that needs quotes
18
- return `[${nodeName}="${value}"]`;
19
- }
20
-
21
- return `[${nodeName}]`;
22
- }
23
- }
24
-
25
- return null;
26
- };
@@ -1,28 +0,0 @@
1
- /**
2
- * Returns the data-{dataAttr} selector of the element
3
- * @param { String } selectorType - The type of selector to return.
4
- * @param { String } attributes - The attributes of the element.
5
- * @return { String | null } - The data-{dataAttr} selector of the element.
6
- */
7
-
8
- export const getData = ( selectorType, attributes ) =>
9
- {
10
- for ( let i = 0; i < attributes.length; i++ )
11
- {
12
- // extract node name + value
13
- const { nodeName, value } = attributes[ i ];
14
-
15
- // if this matches our selector
16
- if ( nodeName === selectorType )
17
- {
18
- if ( value ) {
19
- // if we have value that needs quotes
20
- return `[${nodeName}="${value}"]`;
21
- }
22
-
23
- return `[${nodeName}]`;
24
- }
25
- }
26
-
27
- return null;
28
- };
@@ -1,29 +0,0 @@
1
- /**
2
- * Returns the data-{dataAttr} selector of the element
3
- * @param { String } selectorType - The type of selector to return.
4
- * @param { String } attributes - The attributes of the element.
5
- * @return { String | null } - The data-{dataAttr} selector of the element.
6
- */
7
-
8
- export const getData = ( selectorType, attributes ) =>
9
- {
10
- for ( let i = 0; i < attributes.length; i++ )
11
- {
12
- // extract node name + value
13
- const { nodeName, value } = attributes[ i ];
14
-
15
- // if this matches our selector
16
- if ( nodeName === selectorType )
17
- {
18
- if ( value )
19
- {
20
- // if we have value that needs quotes
21
- return `[${nodeName}="${value}"]`;
22
- }
23
-
24
- return `[${nodeName}]`;
25
- }
26
- }
27
-
28
- return null;
29
- };
@@ -1,131 +0,0 @@
1
- const jsdom = require( 'mocha-jsdom' );
2
- const expect = require( 'chai' ).expect;
3
- import unique from '../src';
4
-
5
- const $ = require( 'jquery' )( require( 'jsdom' ).jsdom().defaultView );
6
-
7
- describe( 'Unique Selector Tests', () =>
8
- {
9
- jsdom( { skipWindowCheck : true } );
10
-
11
- it( 'ID', () =>
12
- {
13
- $( 'body' ).get( 0 ).innerHTML = ''; //Clear previous appends
14
- $( 'body' ).append( '<div id="so" class="test3"></div>' );
15
- const findNode = $( 'body' ).find( '.test3' ).get( 0 );
16
- const uniqueSelector = unique( findNode );
17
- expect( uniqueSelector ).to.equal( '#so' );
18
- } );
19
-
20
- it( 'ID that needs escaping', () =>
21
- {
22
- $( 'body' ).get( 0 ).innerHTML = ''; //Clear previous appends
23
- $( 'body' ).append( '<div id="123" class="test3"></div>' );
24
- const findNode = $( 'body' ).find( '.test3' ).get( 0 );
25
- const uniqueSelector = unique( findNode );
26
- expect( uniqueSelector ).to.equal( '#\\31 23' );
27
- } );
28
-
29
- it( 'Class', () =>
30
- {
31
- $( 'body' ).get( 0 ).innerHTML = ''; //Clear previous appends
32
- $( 'body' ).append( '<div class="test2"></div>' );
33
- const findNode = $( 'body' ).find( '.test2' ).get( 0 );
34
- const uniqueSelector = unique( findNode );
35
- expect( uniqueSelector ).to.equal( '.test2' );
36
- } );
37
-
38
- it( 'Class that needs escaping', () =>
39
- {
40
- $( 'body' ).get( 0 ).innerHTML = ''; //Clear previous appends
41
- $( 'body' ).append( '<div class="@test test2"></div>' );
42
- const findNode = $( 'body' ).find( '.test2' ).get( 0 );
43
- const uniqueSelector = unique( findNode );
44
- expect( uniqueSelector ).to.equal( '.\\@test' );
45
- } );
46
-
47
- it( 'Classes', () =>
48
- {
49
- $( 'body' ).get( 0 ).innerHTML = ''; //Clear previous appends
50
- $( 'body' ).append( '<div class="test2"></div><div class="test2"></div>' );
51
- const findNode = $( 'body' ).find( '.test2' ).get( 0 );
52
- const uniqueSelector = unique( findNode );
53
- expect( uniqueSelector ).to.equal( 'body > :nth-child(1)' );
54
- } );
55
-
56
- it( 'Classes', () =>
57
- {
58
- $( 'body' ).get( 0 ).innerHTML = ''; //Clear previous appends
59
- $( 'body' ).append( '<div class="test2 ca cb cc cd cx"></div><div class="test2 ca cb cc cd ce"></div><div class="test2 ca cb cc cd ce"></div><div class="test2 ca cb cd ce cf cx"></div>' );
60
- const findNode = $( 'body' ).find( '.test2' ).get( 0 );
61
- const uniqueSelector = unique( findNode );
62
- expect( uniqueSelector ).to.equal( '.cc.cx' );
63
- } );
64
-
65
- it( 'Classes with newline', () =>
66
- {
67
- $( 'body' ).get( 0 ).innerHTML = ''; //Clear previous appends
68
- $( 'body' ).append( '<div class="test2\n ca\n cb\n cc\n cd\n cx"></div><div class="test2\n ca\n cb\n cc\n cd\n ce"></div><div class="test2\n ca\n cb\n cc\n cd\n ce"></div><div class="test2\n ca\n cb\n cd\n ce\n cf\n cx"></div>' );
69
- const findNode = $( 'body' ).find( '.test2' ).get( 0 );
70
- const uniqueSelector = unique( findNode );
71
- expect( uniqueSelector ).to.equal( '.cc.cx' );
72
- } );
73
-
74
- it( 'Tag', () =>
75
- {
76
- $( 'body' ).get( 0 ).innerHTML = ''; //Clear previous appends
77
- $( 'body' ).append( '<div class="test2"><span></span></div><div class="test2"></div>' );
78
- const findNode = $( '.test2' ).find( 'span' ).get( 0 );
79
- const uniqueSelector = unique( findNode );
80
- expect( uniqueSelector ).to.equal( 'span' );
81
- } );
82
-
83
-
84
- it( 'Tag', () =>
85
- {
86
- $( 'body' ).get( 0 ).innerHTML = ''; //Clear previous appends
87
- $( 'body' ).append( '<div class="test5"><span></span></div><div class="test5"><span></span></div>' );
88
- const findNode = $( '.test5' ).find( 'span' ).get( 0 );
89
- const uniqueSelector = unique( findNode );
90
- expect( uniqueSelector ).to.equal( ':nth-child(1) > span' );
91
- } );
92
-
93
- it( 'Tag', () =>
94
- {
95
- $( 'body' ).get( 0 ).innerHTML = ''; //Clear previous appends
96
- $( 'body' ).append( '<div class="test5"><span><ul><li><a></a></li></ul></span></div><div class="test5"><span></span></div>' );
97
- const findNode = $( '.test5' ).find( 'a' ).get( 0 );
98
- const uniqueSelector = unique( findNode );
99
- expect( uniqueSelector ).to.equal( 'a' );
100
- } );
101
-
102
- it( 'Attributes', () =>
103
- {
104
- $( 'body' ).get( 0 ).innerHTML = ''; //Clear previous appends
105
- $( 'body' ).append( '<div class="test5" test="5"></div>' );
106
- const findNode = $( '.test5' ).get( 0 );
107
- const uniqueSelector = unique( findNode, { selectorTypes : ['attributes'] });
108
- expect( uniqueSelector ).to.equal( '[test="5"]' );
109
- } );
110
-
111
- it( 'data-foo', () =>
112
- {
113
- $( 'body' ).get( 0 ).innerHTML = ''; //Clear previous appends
114
- $( 'body' ).append( '<div data-foo="so" class="test6"></div>' );
115
- const findNode = $( 'body' ).find( '.test6' ).get( 0 );
116
- findNode.dataset = { foo : 'so' }
117
- const uniqueSelector = unique( findNode, { selectorTypes : ['data-foo'] } );
118
- expect( uniqueSelector ).to.equal( '[data-foo=so]' );
119
- } );
120
-
121
- it( 'data-foo that needs escaping', () =>
122
- {
123
- $( 'body' ).get( 0 ).innerHTML = ''; //Clear previous appends
124
- $( 'body' ).append( '<div data-foo="123" class="test7"></div>' );
125
- const findNode = $( 'body' ).find( '.test7' ).get( 0 );
126
- findNode.dataset = { foo : '123' }
127
- const uniqueSelector = unique( findNode, { selectorTypes : ['data-foo'] } );
128
- expect( uniqueSelector ).to.equal( '[data-foo=\\31 23]' );
129
- } );
130
-
131
- } );