namespaces.js
3.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
"use strict";
var _helpers = require("./util/helpers");
(0, _helpers.test)('match tags in the postcss namespace', 'postcss|button', function (t, tree) {
t.deepEqual(tree.nodes[0].nodes[0].namespace, 'postcss');
t.deepEqual(tree.nodes[0].nodes[0].value, 'button');
});
(0, _helpers.test)('match everything in the postcss namespace', 'postcss|*', function (t, tree) {
t.deepEqual(tree.nodes[0].nodes[0].namespace, 'postcss');
t.deepEqual(tree.nodes[0].nodes[0].value, '*');
});
(0, _helpers.test)('match any namespace', '*|button', function (t, tree) {
t.deepEqual(tree.nodes[0].nodes[0].namespace, '*');
t.deepEqual(tree.nodes[0].nodes[0].value, 'button');
});
(0, _helpers.test)('match all elements within the postcss namespace', 'postcss|*', function (t, tree) {
t.deepEqual(tree.nodes[0].nodes[0].namespace, 'postcss');
t.deepEqual(tree.nodes[0].nodes[0].value, '*');
});
(0, _helpers.test)('match all elements in all namespaces', '*|*', function (t, tree) {
t.deepEqual(tree.nodes[0].nodes[0].namespace, '*');
t.deepEqual(tree.nodes[0].nodes[0].value, '*');
});
(0, _helpers.test)('match all elements without a namespace', '|*', function (t, tree) {
t.deepEqual(tree.nodes[0].nodes[0].namespace, true);
t.deepEqual(tree.nodes[0].nodes[0].value, '*');
});
(0, _helpers.test)('match tags with no namespace', '|button', function (t, tree) {
t.deepEqual(tree.nodes[0].nodes[0].namespace, true);
t.deepEqual(tree.nodes[0].nodes[0].value, 'button');
});
(0, _helpers.test)('match namespace inside attribute selector', '[postcss|href=test]', function (t, tree) {
t.deepEqual(tree.nodes[0].nodes[0].namespace, 'postcss');
t.deepEqual(tree.nodes[0].nodes[0].value, 'test');
});
(0, _helpers.test)('match namespace inside attribute selector (2)', '[postcss|href]', function (t, tree) {
t.deepEqual(tree.nodes[0].nodes[0].namespace, 'postcss');
t.deepEqual(tree.nodes[0].nodes[0].attribute, 'href');
});
(0, _helpers.test)('match namespace inside attribute selector (3)', '[*|href]', function (t, tree) {
t.deepEqual(tree.nodes[0].nodes[0].namespace, '*');
t.deepEqual(tree.nodes[0].nodes[0].attribute, 'href');
});
(0, _helpers.test)('match default namespace inside attribute selector', '[|href]', function (t, tree) {
t.deepEqual(tree.nodes[0].nodes[0].namespace, true);
t.deepEqual(tree.nodes[0].nodes[0].attribute, 'href');
});
(0, _helpers.test)('match default namespace inside attribute selector with spaces', '[ |href ]', function (t, tree) {
t.deepEqual(tree.nodes[0].nodes[0].namespace, true);
t.deepEqual(tree.nodes[0].nodes[0].attribute, 'href');
});
(0, _helpers.test)('namespace with qualified id selector', 'ns|h1#foo', function (t, tree) {
t.deepEqual(tree.nodes[0].nodes[0].namespace, 'ns');
});
(0, _helpers.test)('namespace with qualified class selector', 'ns|h1.foo', function (t, tree) {
t.deepEqual(tree.nodes[0].nodes[0].namespace, 'ns');
});
(0, _helpers.test)('ns alias for namespace', 'f\\oo|h1.foo', function (t, tree) {
var tag = tree.nodes[0].nodes[0];
t.deepEqual(tag.namespace, 'foo');
t.deepEqual(tag.ns, 'foo');
tag.ns = "bar";
t.deepEqual(tag.namespace, 'bar');
t.deepEqual(tag.ns, 'bar');
});