Commit 9ba09659 9ba0965926adddf638fb046e6d33cbcf2ad8029a by zhanghao

commit

1 parent 13ad2c1f
Showing 1000 changed files with 4913 additions and 0 deletions

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.

1 MIT License
2
3 Copyright (c) Microsoft Corporation.
4
5 Permission is hereby granted, free of charge, to any person obtaining a copy
6 of this software and associated documentation files (the "Software"), to deal
7 in the Software without restriction, including without limitation the rights
8 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 copies of the Software, and to permit persons to whom the Software is
10 furnished to do so, subject to the following conditions:
11
12 The above copyright notice and this permission notice shall be included in all
13 copies or substantial portions of the Software.
14
15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 SOFTWARE
1 # Installation
2 > `npm install --save @types/q`
3
4 # Summary
5 This package contains type definitions for Q (https://github.com/kriskowal/q).
6
7 # Details
8 Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/q.
9
10 ### Additional Details
11 * Last updated: Fri, 15 May 2020 23:04:11 GMT
12 * Dependencies: none
13 * Global values: `Q`
14
15 # Credits
16 These definitions were written by [Barrie Nemetchek](https://github.com/bnemetchek), [Andrew Gaspar](https://github.com/AndrewGaspar), [John Reilly](https://github.com/johnnyreilly), [Michel Boudreau](https://github.com/mboudreau), and [TeamworkGuy2](https://github.com/TeamworkGuy2).
1 {
2 "_from": "@types/q@^1.5.1",
3 "_id": "@types/q@1.5.4",
4 "_inBundle": false,
5 "_integrity": "sha512-1HcDas8SEj4z1Wc696tH56G8OlRaH/sqZOynNNB+HF0WOeXPaxTtbYzJY2oEfiUxjSKjhCKr+MvR7dCHcEelug==",
6 "_location": "/@types/q",
7 "_phantomChildren": {},
8 "_requested": {
9 "type": "range",
10 "registry": true,
11 "raw": "@types/q@^1.5.1",
12 "name": "@types/q",
13 "escapedName": "@types%2fq",
14 "scope": "@types",
15 "rawSpec": "^1.5.1",
16 "saveSpec": null,
17 "fetchSpec": "^1.5.1"
18 },
19 "_requiredBy": [
20 "/cssnano-preset-default/coa"
21 ],
22 "_resolved": "https://registry.npmjs.org/@types/q/-/q-1.5.4.tgz",
23 "_shasum": "15925414e0ad2cd765bfef58842f7e26a7accb24",
24 "_spec": "@types/q@^1.5.1",
25 "_where": "/Users/zhanghao/brcode/br-client/node_modules/cssnano-preset-default/node_modules/coa",
26 "bugs": {
27 "url": "https://github.com/DefinitelyTyped/DefinitelyTyped/issues"
28 },
29 "bundleDependencies": false,
30 "contributors": [
31 {
32 "name": "Barrie Nemetchek",
33 "url": "https://github.com/bnemetchek"
34 },
35 {
36 "name": "Andrew Gaspar",
37 "url": "https://github.com/AndrewGaspar"
38 },
39 {
40 "name": "John Reilly",
41 "url": "https://github.com/johnnyreilly"
42 },
43 {
44 "name": "Michel Boudreau",
45 "url": "https://github.com/mboudreau"
46 },
47 {
48 "name": "TeamworkGuy2",
49 "url": "https://github.com/TeamworkGuy2"
50 }
51 ],
52 "dependencies": {},
53 "deprecated": false,
54 "description": "TypeScript definitions for Q",
55 "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped#readme",
56 "license": "MIT",
57 "main": "",
58 "name": "@types/q",
59 "repository": {
60 "type": "git",
61 "url": "git+https://github.com/DefinitelyTyped/DefinitelyTyped.git",
62 "directory": "types/q"
63 },
64 "scripts": {},
65 "typeScriptVersion": "3.0",
66 "types": "index.d.ts",
67 "typesPublisherContentHash": "468c45fb0acfd51599db9fd0186f40568f238a731e9d591452de2c66ac244221",
68 "version": "1.5.4"
69 }
1 # This is the official list of Autoprefixer authors for copyright purposes.
2 #
3 # This does not necessarily list everyone who has contributed code, since in
4 # some cases, their employer may be the copyright holder. To see the full list
5 # of contributors, see the revision history in source control or
6 # https://github.com/postcss/autoprefixer/graphs/contributors
7 #
8 # Authors who wish to be recognized in this file should add themselves (or
9 # their employer, as appropriate).
10
11 Aaron <me@aaron.md>
12 Adam Lynch <contact@adamlynch.ie>
13 Adonis K <aklp08@gmail.com>
14 Adriaan <https://github.com/harianus>
15 Aleksei Androsov <aandrosov@yandex-team.ru>
16 Aleksey Shvayka <shvaikalesh@gmail.com>
17 Aleks Hudochenkov <aleks@hudochenkov.com>
18 Alexey Komarov <alex7kom@gmail.com>
19 Alexey Plutalov <demiazz.py@gmail.com>
20 Anders Olsen Sandvik <https://github.com/Andersos>
21 Andreas Haller <Andreas.Haller@invision.de>
22 Andreas Lind <andreas@one.com>
23 Andrew Rhoads <andrew.c.rhoads@gmail.com
24 Andrey Deryabin <deriabin@gmail.com>
25 Andrey Sitnik <andrey@sitnik.ru>
26 Andrey Taritsyn <taritsyn@gmail.com>
27 Andy Trevorah <a.trevorah@gmail.com>
28 Anton Khlynovskiy <subzey@gmail.com>
29 Artem Yavorsky <info@yavorsky.org>
30 aruseni <aruseni.magiku@gmail.com>
31 Ben Briggs <beneb.info@gmail.com>
32 bernig <https://github.com/bernig>
33 Bogdan Chadkin <trysound@yandex.ru>
34 brainopia <brainopia@evilmartians.com>
35 Brandon Mathis <brandon@imathis.com>
36 Chad von Nau <chad@vonnau.com>
37 Chi Vinh Le <vinh@wikiwi.io>
38 Cory House <housecor@gmail.com>
39 Cory Simmons <cory@mojotech.com>
40 Craig Martin <https://github.com/craigmichaelmartin>
41 Damon <motoxer4533@gmail.com>
42 Daniel Garcia-Carrillo <garciacarrillo.daniel@gmail.com>
43 Daniel Tschinder <daniel@tschinder.de>
44 Danny Pule <kojikusan@gmail.com>
45 Darius
46 David Narbutovich <vamnemne@gmail.com>
47 David Pike <david@evolution7.com.au>
48 Denis Sokolov <denis@sokolov.cc>
49 Dominik Porada <dominik@porada.co>
50 Dominik Schilling <dominikschilling+git@gmail.com>
51 dotch <ch.weiss@hotmail.de>
52 Dmitry Semigradsky <semigradskyd@gmail.com>
53 Efremov Alexey <lexich121@gmail.com>
54 eitanr <eitanr@wix.com>
55 Erik Sundahl <esundahl@gmail.com>
56 Eugene Datsky <eugene@datsky.ru>
57 Evgeny Petukhov <petukhov.yevgeny@gmail.com>
58 Evilebot Tnawi <sheo13666q@gmail.com>
59 Fangzhou Li <riophaelee@gmail.com>
60 Forrest York <https://github.com/badisa>
61 Google Inc.
62 Gregory Eremin <magnolia_fan@me.com>
63 GU Yiling <justice360@gmail.com>
64 Hallvord R. M. Steen <hallvord@hallvord.com>
65 heady <https://github.com/heady>
66 Iain Beeston <iain.beeston@gmail.com>
67 Igor Adamenko <https://github.com/igoradamenko>
68 Jack Moore <hello@jacklmoore.com>
69 Jason Kuhrt <jasonkuhrt@me.com>
70 Jeff Escalante <hello@jenius.me>
71 Joan León <joan.leon@gmail.com>
72 Johannes J. Schmidt <schmidt@netzmerk.com>
73 John Kreitlow <jkreitlow@deepfocus.net>
74 Jonathan Ong <jonathanrichardong@gmail.com>
75 Josh Gillies <github@joshgilli.es>
76 Junliang Huang
77 jvdanilo <jvdanilo@gmail.com>
78 Kevin Pfefferle <kevin@rebaseinteractive.com>
79 Kieran <Kieranju@gmail.com>
80 Kir Shatrov <shatrov@me.com>
81 Kiwi <vinh@wikiwi.io>
82 kizu <kizmarh@gmail.com>
83 Leonya Khachaturov <leonidkhachaturov@gmail.com>
84 Lovchikov Anton <besyanya@yandex.ru>
85 L.T <ec.huyinghuan@gmail.com>
86 Lucas Caton <lucascaton@gmail.com>
87 Luciano Battagliero <lucianobattagliero+git@gmail.com>
88 Luke Page <luke.a.page@gmail.com>
89 martco <martco@gmail.com>
90 Matt Smith <runner_28@hotmail.com>
91 Maxime Thirouin <m@moox.io>
92 Max Mechanic <max@philo.com>
93 Michael Beil <michaelbeil@me.com>
94 Michael Scott Hertzberg <mshertzberg@gmail.com>
95 Michał Gołębiowski-Owczarek <m.goleb@gmail.com>
96 Mikael Jorhult <mikael@jorhult.se>
97 Morton Fox <github@qslw.com>
98 mvasilkov <mvasilkov@gmail.com>
99 Nick Howes <nick@nickhowes.co.uk>
100 Nick Marchenko <n30n1ck@gmail.com>
101 Nick Schonning <nschonni@gmail.com>
102 nickspielgist <dev@nickspiel.me>
103 Niels Dequeker <niels.dequeker@gmail.com>
104 Nikolay Burlov <kohgpat@gmail.com>
105 Oleksandr Sergiienko <sigerello@gmail.com>
106 Pavel Pustovalov <pustovalov.pavel@gmail.com>
107 Paul Statezny <Paulstatezny@gmail.com>
108 Peter van Westen <info@regularlabs.com>
109 Peter Zotov <whitequark@whitequark.org>
110 Phil Dokas <phil@jetless.org>
111 Rafael Silva <rafael@rafaelsilva.net>
112 Ray Lehnhoff <raymond.lehnhoff@gmail.com>
113 ReadmeCritic <frankensteinbot@gmail.com>
114 Reinaldo Schiehll <rn.schiehll@gmail.com>
115 René Stalder <rene@whatwedo.ch>
116 Richard Wang <richardwa@google.com>
117 Rob Howell <rob@robhowell.com>
118 Roland Warmerdam <rowno@webspirited.com>
119 Roman Dvornov <rdvornov@gmail.com>
120 Ryan Zimmerman
121 Sami Suo-Heikki <suoheikki.sami@gmail.com>
122 Sasha Koss <koss@nocorp.me>
123 Sean Anderson <Sean.Palmer.Anderson@gmail.com>
124 Sergey Belov <peimei@ya.ru>
125 Sergey Leschina <mail@putnik.ws>
126 sethjgore <sethjgore@gmail.com>
127 Šime Vidas <sime.vidas@gmail.com>
128 Simon Lydell <simon.lydell@gmail.com>
129 Sindre Sorhus <sindresorhus@gmail.com>
130 Stephen Edgar <stephen@netweb.com.au>
131 Steve Mao <https://github.com/stevemao>
132 Stig Otnes Kolstad <stig@stigok.net>
133 Subash Pathak <sbspk@msn.com>
134 sunhao <sunhao_1988@msn.cn>
135 tomdavenport <playmusic@me.com>
136 Tony Ganch <tonyganch@gmail.com>
137 Vegard Andreas Larsen <vegard@xaltra.net>
138 Vera Surkova <vera@surkova.se>
139 Vincent De Oliveira <vincent@iamvdo.me>
140 Vishnu Ravi <vishnu@vishnu.io>
141 Vladimir Pouzanov <farcaller@gmail.com>
142 vladkens <vladkens@yandex.ru>
143 Yet Another Minion <yam@thinkalexandria.com>
144 Даниил Пронин <mail@grawl.ru>
145 一丝 <jie.lijie@alibaba-inc.com>
146 刘祺 <gucong@gmail.com>
147 忆初 <baby@justjavac.com>
1 The MIT License (MIT)
2
3 Copyright 2013 Andrey Sitnik <andrey@sitnik.ru>
4
5 Permission is hereby granted, free of charge, to any person obtaining a copy of
6 this software and associated documentation files (the "Software"), to deal in
7 the Software without restriction, including without limitation the rights to
8 use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 the Software, and to permit persons to whom the Software is furnished to do so,
10 subject to the following conditions:
11
12 The above copyright notice and this permission notice shall be included in all
13 copies or substantial portions of the Software.
14
15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17 FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18 COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1 #!/usr/bin/env node
2
3 process.stdout.write(require('../')().info() + '\n');
1 'use strict';
2
3 function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }
4
5 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
7 function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
8
9 function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : _defaults(subClass, superClass); }
10
11 var Prefixer = require('./prefixer');
12
13 var AtRule = function (_Prefixer) {
14 _inherits(AtRule, _Prefixer);
15
16 function AtRule() {
17 _classCallCheck(this, AtRule);
18
19 return _possibleConstructorReturn(this, _Prefixer.apply(this, arguments));
20 }
21
22 /**
23 * Clone and add prefixes for at-rule
24 */
25 AtRule.prototype.add = function add(rule, prefix) {
26 var prefixed = prefix + rule.name;
27
28 var already = rule.parent.some(function (i) {
29 return i.name === prefixed && i.params === rule.params;
30 });
31 if (already) {
32 return undefined;
33 }
34
35 var cloned = this.clone(rule, { name: prefixed });
36 return rule.parent.insertBefore(rule, cloned);
37 };
38
39 /**
40 * Clone node with prefixes
41 */
42
43
44 AtRule.prototype.process = function process(node) {
45 var parent = this.parentPrefix(node);
46
47 for (var _iterator = this.prefixes, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
48 var _ref;
49
50 if (_isArray) {
51 if (_i >= _iterator.length) break;
52 _ref = _iterator[_i++];
53 } else {
54 _i = _iterator.next();
55 if (_i.done) break;
56 _ref = _i.value;
57 }
58
59 var prefix = _ref;
60
61 if (!parent || parent === prefix) {
62 this.add(node, prefix);
63 }
64 }
65 };
66
67 return AtRule;
68 }(Prefixer);
69
70 module.exports = AtRule;
...\ No newline at end of file ...\ No newline at end of file
1 'use strict';
2
3 var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
4
5 var browserslist = require('browserslist');
6 var postcss = require('postcss');
7
8 var Browsers = require('./browsers');
9 var Prefixes = require('./prefixes');
10
11 function isPlainObject(obj) {
12 return Object.prototype.toString.apply(obj) === '[object Object]';
13 }
14
15 var cache = {};
16
17 function timeCapsule(result, prefixes) {
18 if (prefixes.browsers.selected.length === 0) {
19 return;
20 }
21 if (prefixes.add.selectors.length > 0) {
22 return;
23 }
24 if (Object.keys(prefixes.add).length > 2) {
25 return;
26 }
27
28 /* istanbul ignore next */
29 result.warn('Greetings, time traveller. ' + 'We are in the golden age of prefix-less CSS, ' + 'where Autoprefixer is no longer needed for your stylesheet.');
30 }
31
32 module.exports = postcss.plugin('autoprefixer', function () {
33 for (var _len = arguments.length, reqs = Array(_len), _key = 0; _key < _len; _key++) {
34 reqs[_key] = arguments[_key];
35 }
36
37 var options = void 0;
38 if (reqs.length === 1 && isPlainObject(reqs[0])) {
39 options = reqs[0];
40 reqs = undefined;
41 } else if (reqs.length === 0 || reqs.length === 1 && !reqs[0]) {
42 reqs = undefined;
43 } else if (reqs.length <= 2 && (reqs[0] instanceof Array || !reqs[0])) {
44 options = reqs[1];
45 reqs = reqs[0];
46 } else if (_typeof(reqs[reqs.length - 1]) === 'object') {
47 options = reqs.pop();
48 }
49
50 if (!options) {
51 options = {};
52 }
53
54 if (options.browser) {
55 throw new Error('Change `browser` option to `browsers` in Autoprefixer');
56 } else if (options.browserslist) {
57 throw new Error('Change `browserslist` option to `browsers` in Autoprefixer');
58 }
59
60 if (options.browsers) {
61 reqs = options.browsers;
62 }
63
64 if (typeof options.grid === 'undefined') {
65 options.grid = false;
66 }
67
68 var loadPrefixes = function loadPrefixes(opts) {
69 var data = module.exports.data;
70 var browsers = new Browsers(data.browsers, reqs, opts, options.stats);
71 var key = browsers.selected.join(', ') + JSON.stringify(options);
72
73 if (!cache[key]) {
74 cache[key] = new Prefixes(data.prefixes, browsers, options);
75 }
76
77 return cache[key];
78 };
79
80 var plugin = function plugin(css, result) {
81 var prefixes = loadPrefixes({
82 from: css.source && css.source.input.file,
83 env: options.env
84 });
85 timeCapsule(result, prefixes);
86 if (options.remove !== false) {
87 prefixes.processor.remove(css, result);
88 }
89 if (options.add !== false) {
90 prefixes.processor.add(css, result);
91 }
92 };
93
94 plugin.options = options;
95
96 plugin.browsers = reqs;
97
98 plugin.info = function (opts) {
99 opts = opts || {};
100 opts.from = opts.from || process.cwd();
101
102 return require('./info')(loadPrefixes(opts));
103 };
104
105 return plugin;
106 });
107
108 /**
109 * Autoprefixer data
110 */
111 module.exports.data = {
112 browsers: require('caniuse-lite').agents,
113 prefixes: require('../data/prefixes')
114 };
115
116 /**
117 * Autoprefixer default browsers
118 */
119 module.exports.defaults = browserslist.defaults;
120
121 /**
122 * Inspect with default Autoprefixer
123 */
124 module.exports.info = function () {
125 return module.exports().info();
126 };
...\ No newline at end of file ...\ No newline at end of file
1 'use strict';
2
3 var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
4
5 var last = function last(array) {
6 return array[array.length - 1];
7 };
8
9 var brackets = {
10
11 /**
12 * Parse string to nodes tree
13 */
14 parse: function parse(str) {
15 var current = [''];
16 var stack = [current];
17
18 for (var i = 0; i < str.length; i++) {
19 var sym = str[i];
20 if (sym === '(') {
21 current = [''];
22 last(stack).push(current);
23 stack.push(current);
24 continue;
25 }
26
27 if (sym === ')') {
28 stack.pop();
29 current = last(stack);
30 current.push('');
31 continue;
32 }
33
34 current[current.length - 1] += sym;
35 }
36
37 return stack[0];
38 },
39
40
41 /**
42 * Generate output string by nodes tree
43 */
44 stringify: function stringify(ast) {
45 var result = '';
46 for (var _iterator = ast, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
47 var _ref;
48
49 if (_isArray) {
50 if (_i >= _iterator.length) break;
51 _ref = _iterator[_i++];
52 } else {
53 _i = _iterator.next();
54 if (_i.done) break;
55 _ref = _i.value;
56 }
57
58 var i = _ref;
59
60 if ((typeof i === 'undefined' ? 'undefined' : _typeof(i)) === 'object') {
61 result += '(' + brackets.stringify(i) + ')';
62 continue;
63 }
64
65 result += i;
66 }
67 return result;
68 }
69 };
70
71 module.exports = brackets;
...\ No newline at end of file ...\ No newline at end of file
1 'use strict';
2
3 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
4
5 var browserslist = require('browserslist');
6
7 var utils = require('./utils');
8
9 var Browsers = function () {
10
11 /**
12 * Return all prefixes for default browser data
13 */
14 Browsers.prefixes = function prefixes() {
15 if (this.prefixesCache) {
16 return this.prefixesCache;
17 }
18
19 var data = require('caniuse-lite').agents;
20
21 this.prefixesCache = [];
22 for (var name in data) {
23 this.prefixesCache.push('-' + data[name].prefix + '-');
24 }
25
26 this.prefixesCache = utils.uniq(this.prefixesCache).sort(function (a, b) {
27 return b.length - a.length;
28 });
29
30 return this.prefixesCache;
31 };
32
33 /**
34 * Check is value contain any possibe prefix
35 */
36
37
38 Browsers.withPrefix = function withPrefix(value) {
39 if (!this.prefixesRegexp) {
40 this.prefixesRegexp = new RegExp(this.prefixes().join('|'));
41 }
42
43 return this.prefixesRegexp.test(value);
44 };
45
46 function Browsers(data, requirements, options, stats) {
47 _classCallCheck(this, Browsers);
48
49 this.data = data;
50 this.options = options || {};
51 this.stats = stats;
52 this.selected = this.parse(requirements);
53 }
54
55 /**
56 * Return browsers selected by requirements
57 */
58
59
60 Browsers.prototype.parse = function parse(requirements) {
61 return browserslist(requirements, {
62 stats: this.stats,
63 path: this.options.from,
64 env: this.options.env
65 });
66 };
67
68 /**
69 * Return prefix for selected browser
70 */
71
72
73 Browsers.prototype.prefix = function prefix(browser) {
74 var _browser$split = browser.split(' '),
75 name = _browser$split[0],
76 version = _browser$split[1];
77
78 var data = this.data[name];
79
80 var prefix = data.prefix_exceptions && data.prefix_exceptions[version];
81 if (!prefix) {
82 prefix = data.prefix;
83 }
84 return '-' + prefix + '-';
85 };
86
87 /**
88 * Is browser is selected by requirements
89 */
90
91
92 Browsers.prototype.isSelected = function isSelected(browser) {
93 return this.selected.indexOf(browser) !== -1;
94 };
95
96 return Browsers;
97 }();
98
99 module.exports = Browsers;
...\ No newline at end of file ...\ No newline at end of file
1 'use strict';
2
3 function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }
4
5 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
7 function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
8
9 function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : _defaults(subClass, superClass); }
10
11 var Prefixer = require('./prefixer');
12 var Browsers = require('./browsers');
13 var utils = require('./utils');
14
15 var Declaration = function (_Prefixer) {
16 _inherits(Declaration, _Prefixer);
17
18 function Declaration() {
19 _classCallCheck(this, Declaration);
20
21 return _possibleConstructorReturn(this, _Prefixer.apply(this, arguments));
22 }
23
24 /**
25 * Always true, because we already get prefixer by property name
26 */
27 Declaration.prototype.check = function check() /* decl */{
28 return true;
29 };
30
31 /**
32 * Return prefixed version of property
33 */
34
35
36 Declaration.prototype.prefixed = function prefixed(prop, prefix) {
37 return prefix + prop;
38 };
39
40 /**
41 * Return unprefixed version of property
42 */
43
44
45 Declaration.prototype.normalize = function normalize(prop) {
46 return prop;
47 };
48
49 /**
50 * Check `value`, that it contain other prefixes, rather than `prefix`
51 */
52
53
54 Declaration.prototype.otherPrefixes = function otherPrefixes(value, prefix) {
55 for (var _iterator = Browsers.prefixes(), _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
56 var _ref;
57
58 if (_isArray) {
59 if (_i >= _iterator.length) break;
60 _ref = _iterator[_i++];
61 } else {
62 _i = _iterator.next();
63 if (_i.done) break;
64 _ref = _i.value;
65 }
66
67 var other = _ref;
68
69 if (other === prefix) {
70 continue;
71 }
72 if (value.indexOf(other) !== -1) {
73 return true;
74 }
75 }
76 return false;
77 };
78
79 /**
80 * Set prefix to declaration
81 */
82
83
84 Declaration.prototype.set = function set(decl, prefix) {
85 decl.prop = this.prefixed(decl.prop, prefix);
86 return decl;
87 };
88
89 /**
90 * Should we use visual cascade for prefixes
91 */
92
93
94 Declaration.prototype.needCascade = function needCascade(decl) {
95 if (!decl._autoprefixerCascade) {
96 decl._autoprefixerCascade = this.all.options.cascade !== false && decl.raw('before').indexOf('\n') !== -1;
97 }
98 return decl._autoprefixerCascade;
99 };
100
101 /**
102 * Return maximum length of possible prefixed property
103 */
104
105
106 Declaration.prototype.maxPrefixed = function maxPrefixed(prefixes, decl) {
107 if (decl._autoprefixerMax) {
108 return decl._autoprefixerMax;
109 }
110
111 var max = 0;
112 for (var _iterator2 = prefixes, _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : _iterator2[Symbol.iterator]();;) {
113 var _ref2;
114
115 if (_isArray2) {
116 if (_i2 >= _iterator2.length) break;
117 _ref2 = _iterator2[_i2++];
118 } else {
119 _i2 = _iterator2.next();
120 if (_i2.done) break;
121 _ref2 = _i2.value;
122 }
123
124 var prefix = _ref2;
125
126 prefix = utils.removeNote(prefix);
127 if (prefix.length > max) {
128 max = prefix.length;
129 }
130 }
131 decl._autoprefixerMax = max;
132
133 return decl._autoprefixerMax;
134 };
135
136 /**
137 * Calculate indentation to create visual cascade
138 */
139
140
141 Declaration.prototype.calcBefore = function calcBefore(prefixes, decl) {
142 var prefix = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
143
144 var max = this.maxPrefixed(prefixes, decl);
145 var diff = max - utils.removeNote(prefix).length;
146
147 var before = decl.raw('before');
148 if (diff > 0) {
149 before += Array(diff).fill(' ').join('');
150 }
151
152 return before;
153 };
154
155 /**
156 * Remove visual cascade
157 */
158
159
160 Declaration.prototype.restoreBefore = function restoreBefore(decl) {
161 var lines = decl.raw('before').split('\n');
162 var min = lines[lines.length - 1];
163
164 this.all.group(decl).up(function (prefixed) {
165 var array = prefixed.raw('before').split('\n');
166 var last = array[array.length - 1];
167 if (last.length < min.length) {
168 min = last;
169 }
170 });
171
172 lines[lines.length - 1] = min;
173 decl.raws.before = lines.join('\n');
174 };
175
176 /**
177 * Clone and insert new declaration
178 */
179
180
181 Declaration.prototype.insert = function insert(decl, prefix, prefixes) {
182 var cloned = this.set(this.clone(decl), prefix);
183 if (!cloned) return undefined;
184
185 var already = decl.parent.some(function (i) {
186 return i.prop === cloned.prop && i.value === cloned.value;
187 });
188 if (already) {
189 return undefined;
190 }
191
192 if (this.needCascade(decl)) {
193 cloned.raws.before = this.calcBefore(prefixes, decl, prefix);
194 }
195 return decl.parent.insertBefore(decl, cloned);
196 };
197
198 /**
199 * Did this declaration has this prefix above
200 */
201
202
203 Declaration.prototype.isAlready = function isAlready(decl, prefixed) {
204 var already = this.all.group(decl).up(function (i) {
205 return i.prop === prefixed;
206 });
207 if (!already) {
208 already = this.all.group(decl).down(function (i) {
209 return i.prop === prefixed;
210 });
211 }
212 return already;
213 };
214
215 /**
216 * Clone and add prefixes for declaration
217 */
218
219
220 Declaration.prototype.add = function add(decl, prefix, prefixes, result) {
221 var prefixed = this.prefixed(decl.prop, prefix);
222 if (this.isAlready(decl, prefixed) || this.otherPrefixes(decl.value, prefix)) {
223 return undefined;
224 }
225 return this.insert(decl, prefix, prefixes, result);
226 };
227
228 /**
229 * Add spaces for visual cascade
230 */
231
232
233 Declaration.prototype.process = function process(decl, result) {
234 if (!this.needCascade(decl)) {
235 _Prefixer.prototype.process.call(this, decl, result);
236 return;
237 }
238
239 var prefixes = _Prefixer.prototype.process.call(this, decl, result);
240
241 if (!prefixes || !prefixes.length) {
242 return;
243 }
244
245 this.restoreBefore(decl);
246 decl.raws.before = this.calcBefore(prefixes, decl);
247 };
248
249 /**
250 * Return list of prefixed properties to clean old prefixes
251 */
252
253
254 Declaration.prototype.old = function old(prop, prefix) {
255 return [this.prefixed(prop, prefix)];
256 };
257
258 return Declaration;
259 }(Prefixer);
260
261 module.exports = Declaration;
...\ No newline at end of file ...\ No newline at end of file
1 'use strict';
2
3 function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }
4
5 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
7 function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
8
9 function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : _defaults(subClass, superClass); }
10
11 var flexSpec = require('./flex-spec');
12 var Declaration = require('../declaration');
13
14 var AlignContent = function (_Declaration) {
15 _inherits(AlignContent, _Declaration);
16
17 function AlignContent() {
18 _classCallCheck(this, AlignContent);
19
20 return _possibleConstructorReturn(this, _Declaration.apply(this, arguments));
21 }
22
23 /**
24 * Change property name for 2012 spec
25 */
26 AlignContent.prototype.prefixed = function prefixed(prop, prefix) {
27 var spec = void 0;
28
29 var _flexSpec = flexSpec(prefix);
30
31 spec = _flexSpec[0];
32 prefix = _flexSpec[1];
33
34 if (spec === 2012) {
35 return prefix + 'flex-line-pack';
36 } else {
37 return _Declaration.prototype.prefixed.call(this, prop, prefix);
38 }
39 };
40
41 /**
42 * Return property name by final spec
43 */
44
45
46 AlignContent.prototype.normalize = function normalize() {
47 return 'align-content';
48 };
49
50 /**
51 * Change value for 2012 spec and ignore prefix for 2009
52 */
53
54
55 AlignContent.prototype.set = function set(decl, prefix) {
56 var spec = flexSpec(prefix)[0];
57 if (spec === 2012) {
58 decl.value = AlignContent.oldValues[decl.value] || decl.value;
59 return _Declaration.prototype.set.call(this, decl, prefix);
60 } else if (spec === 'final') {
61 return _Declaration.prototype.set.call(this, decl, prefix);
62 }
63 return undefined;
64 };
65
66 return AlignContent;
67 }(Declaration);
68
69 Object.defineProperty(AlignContent, 'names', {
70 enumerable: true,
71 writable: true,
72 value: ['align-content', 'flex-line-pack']
73 });
74 Object.defineProperty(AlignContent, 'oldValues', {
75 enumerable: true,
76 writable: true,
77 value: {
78 'flex-end': 'end',
79 'flex-start': 'start',
80 'space-between': 'justify',
81 'space-around': 'distribute'
82 }
83 });
84
85
86 module.exports = AlignContent;
...\ No newline at end of file ...\ No newline at end of file
1 'use strict';
2
3 function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }
4
5 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
7 function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
8
9 function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : _defaults(subClass, superClass); }
10
11 var flexSpec = require('./flex-spec');
12 var Declaration = require('../declaration');
13
14 var AlignItems = function (_Declaration) {
15 _inherits(AlignItems, _Declaration);
16
17 function AlignItems() {
18 _classCallCheck(this, AlignItems);
19
20 return _possibleConstructorReturn(this, _Declaration.apply(this, arguments));
21 }
22
23 /**
24 * Change property name for 2009 and 2012 specs
25 */
26 AlignItems.prototype.prefixed = function prefixed(prop, prefix) {
27 var spec = void 0;
28
29 var _flexSpec = flexSpec(prefix);
30
31 spec = _flexSpec[0];
32 prefix = _flexSpec[1];
33
34 if (spec === 2009) {
35 return prefix + 'box-align';
36 } else if (spec === 2012) {
37 return prefix + 'flex-align';
38 } else {
39 return _Declaration.prototype.prefixed.call(this, prop, prefix);
40 }
41 };
42
43 /**
44 * Return property name by final spec
45 */
46
47
48 AlignItems.prototype.normalize = function normalize() {
49 return 'align-items';
50 };
51
52 /**
53 * Change value for 2009 and 2012 specs
54 */
55
56
57 AlignItems.prototype.set = function set(decl, prefix) {
58 var spec = flexSpec(prefix)[0];
59 if (spec === 2009 || spec === 2012) {
60 decl.value = AlignItems.oldValues[decl.value] || decl.value;
61 }
62 return _Declaration.prototype.set.call(this, decl, prefix);
63 };
64
65 return AlignItems;
66 }(Declaration);
67
68 Object.defineProperty(AlignItems, 'names', {
69 enumerable: true,
70 writable: true,
71 value: ['align-items', 'flex-align', 'box-align']
72 });
73 Object.defineProperty(AlignItems, 'oldValues', {
74 enumerable: true,
75 writable: true,
76 value: {
77 'flex-end': 'end',
78 'flex-start': 'start'
79 }
80 });
81
82
83 module.exports = AlignItems;
...\ No newline at end of file ...\ No newline at end of file
1 'use strict';
2
3 function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }
4
5 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
7 function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
8
9 function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : _defaults(subClass, superClass); }
10
11 var flexSpec = require('./flex-spec');
12 var Declaration = require('../declaration');
13
14 var AlignSelf = function (_Declaration) {
15 _inherits(AlignSelf, _Declaration);
16
17 function AlignSelf() {
18 _classCallCheck(this, AlignSelf);
19
20 return _possibleConstructorReturn(this, _Declaration.apply(this, arguments));
21 }
22
23 /**
24 * Change property name for 2012 specs
25 */
26 AlignSelf.prototype.prefixed = function prefixed(prop, prefix) {
27 var spec = void 0;
28
29 var _flexSpec = flexSpec(prefix);
30
31 spec = _flexSpec[0];
32 prefix = _flexSpec[1];
33
34 if (spec === 2012) {
35 return prefix + 'flex-item-align';
36 } else {
37 return _Declaration.prototype.prefixed.call(this, prop, prefix);
38 }
39 };
40
41 /**
42 * Return property name by final spec
43 */
44
45
46 AlignSelf.prototype.normalize = function normalize() {
47 return 'align-self';
48 };
49
50 /**
51 * Change value for 2012 spec and ignore prefix for 2009
52 */
53
54
55 AlignSelf.prototype.set = function set(decl, prefix) {
56 var spec = flexSpec(prefix)[0];
57 if (spec === 2012) {
58 decl.value = AlignSelf.oldValues[decl.value] || decl.value;
59 return _Declaration.prototype.set.call(this, decl, prefix);
60 } else if (spec === 'final') {
61 return _Declaration.prototype.set.call(this, decl, prefix);
62 }
63 return undefined;
64 };
65
66 return AlignSelf;
67 }(Declaration);
68
69 Object.defineProperty(AlignSelf, 'names', {
70 enumerable: true,
71 writable: true,
72 value: ['align-self', 'flex-item-align']
73 });
74 Object.defineProperty(AlignSelf, 'oldValues', {
75 enumerable: true,
76 writable: true,
77 value: {
78 'flex-end': 'end',
79 'flex-start': 'start'
80 }
81 });
82
83
84 module.exports = AlignSelf;
...\ No newline at end of file ...\ No newline at end of file
1 'use strict';
2
3 function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }
4
5 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
7 function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
8
9 function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : _defaults(subClass, superClass); }
10
11 var Declaration = require('../declaration');
12
13 var Animation = function (_Declaration) {
14 _inherits(Animation, _Declaration);
15
16 function Animation() {
17 _classCallCheck(this, Animation);
18
19 return _possibleConstructorReturn(this, _Declaration.apply(this, arguments));
20 }
21
22 /**
23 * Don’t add prefixes for modern values.
24 */
25 Animation.prototype.check = function check(decl) {
26 return !decl.value.split(/\s+/).some(function (i) {
27 var lower = i.toLowerCase();
28 return lower === 'reverse' || lower === 'alternate-reverse';
29 });
30 };
31
32 return Animation;
33 }(Declaration);
34
35 Object.defineProperty(Animation, 'names', {
36 enumerable: true,
37 writable: true,
38 value: ['animation', 'animation-direction']
39 });
40
41
42 module.exports = Animation;
...\ No newline at end of file ...\ No newline at end of file
1 'use strict';
2
3 function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }
4
5 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
7 function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
8
9 function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : _defaults(subClass, superClass); }
10
11 var Declaration = require('../declaration');
12 var utils = require('../utils');
13
14 var Appearance = function (_Declaration) {
15 _inherits(Appearance, _Declaration);
16
17 function Appearance(name, prefixes, all) {
18 _classCallCheck(this, Appearance);
19
20 var _this = _possibleConstructorReturn(this, _Declaration.call(this, name, prefixes, all));
21
22 if (_this.prefixes) {
23 _this.prefixes = utils.uniq(_this.prefixes.map(function (i) {
24 if (i === '-ms-') {
25 return '-webkit-';
26 } else {
27 return i;
28 }
29 }));
30 }
31 return _this;
32 }
33
34 return Appearance;
35 }(Declaration);
36
37 Object.defineProperty(Appearance, 'names', {
38 enumerable: true,
39 writable: true,
40 value: ['appearance']
41 });
42
43
44 module.exports = Appearance;
...\ No newline at end of file ...\ No newline at end of file
1 'use strict';
2
3 function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }
4
5 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
7 function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
8
9 function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : _defaults(subClass, superClass); }
10
11 var Declaration = require('../declaration');
12
13 var BackgroundSize = function (_Declaration) {
14 _inherits(BackgroundSize, _Declaration);
15
16 function BackgroundSize() {
17 _classCallCheck(this, BackgroundSize);
18
19 return _possibleConstructorReturn(this, _Declaration.apply(this, arguments));
20 }
21
22 /**
23 * Duplication parameter for -webkit- browsers
24 */
25 BackgroundSize.prototype.set = function set(decl, prefix) {
26 var value = decl.value.toLowerCase();
27 if (prefix === '-webkit-' && value.indexOf(' ') === -1 && value !== 'contain' && value !== 'cover') {
28 decl.value = decl.value + ' ' + decl.value;
29 }
30 return _Declaration.prototype.set.call(this, decl, prefix);
31 };
32
33 return BackgroundSize;
34 }(Declaration);
35
36 Object.defineProperty(BackgroundSize, 'names', {
37 enumerable: true,
38 writable: true,
39 value: ['background-size']
40 });
41
42
43 module.exports = BackgroundSize;
...\ No newline at end of file ...\ No newline at end of file
1 'use strict';
2
3 function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }
4
5 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
7 function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
8
9 function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : _defaults(subClass, superClass); }
10
11 var Declaration = require('../declaration');
12
13 var BlockLogical = function (_Declaration) {
14 _inherits(BlockLogical, _Declaration);
15
16 function BlockLogical() {
17 _classCallCheck(this, BlockLogical);
18
19 return _possibleConstructorReturn(this, _Declaration.apply(this, arguments));
20 }
21
22 /**
23 * Use old syntax for -moz- and -webkit-
24 */
25 BlockLogical.prototype.prefixed = function prefixed(prop, prefix) {
26 return prefix + (prop.indexOf('-start') !== -1 ? prop.replace('-block-start', '-before') : prop.replace('-block-end', '-after'));
27 };
28
29 /**
30 * Return property name by spec
31 */
32
33
34 BlockLogical.prototype.normalize = function normalize(prop) {
35 if (prop.indexOf('-before') !== -1) {
36 return prop.replace('-before', '-block-start');
37 } else {
38 return prop.replace('-after', '-block-end');
39 }
40 };
41
42 return BlockLogical;
43 }(Declaration);
44
45 Object.defineProperty(BlockLogical, 'names', {
46 enumerable: true,
47 writable: true,
48 value: ['border-block-start', 'border-block-end', 'margin-block-start', 'margin-block-end', 'padding-block-start', 'padding-block-end', 'border-before', 'border-after', 'margin-before', 'margin-after', 'padding-before', 'padding-after']
49 });
50
51
52 module.exports = BlockLogical;
...\ No newline at end of file ...\ No newline at end of file
1 'use strict';
2
3 function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }
4
5 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
7 function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
8
9 function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : _defaults(subClass, superClass); }
10
11 var Declaration = require('../declaration');
12
13 var BorderImage = function (_Declaration) {
14 _inherits(BorderImage, _Declaration);
15
16 function BorderImage() {
17 _classCallCheck(this, BorderImage);
18
19 return _possibleConstructorReturn(this, _Declaration.apply(this, arguments));
20 }
21
22 /**
23 * Remove fill parameter for prefixed declarations
24 */
25 BorderImage.prototype.set = function set(decl, prefix) {
26 decl.value = decl.value.replace(/\s+fill(\s)/, '$1');
27 return _Declaration.prototype.set.call(this, decl, prefix);
28 };
29
30 return BorderImage;
31 }(Declaration);
32
33 Object.defineProperty(BorderImage, 'names', {
34 enumerable: true,
35 writable: true,
36 value: ['border-image']
37 });
38
39
40 module.exports = BorderImage;
...\ No newline at end of file ...\ No newline at end of file
1 'use strict';
2
3 function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }
4
5 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
7 function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
8
9 function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : _defaults(subClass, superClass); }
10
11 var Declaration = require('../declaration');
12
13 var BorderRadius = function (_Declaration) {
14 _inherits(BorderRadius, _Declaration);
15
16 function BorderRadius() {
17 _classCallCheck(this, BorderRadius);
18
19 return _possibleConstructorReturn(this, _Declaration.apply(this, arguments));
20 }
21
22 /**
23 * Change syntax, when add Mozilla prefix
24 */
25 BorderRadius.prototype.prefixed = function prefixed(prop, prefix) {
26 if (prefix === '-moz-') {
27 return prefix + (BorderRadius.toMozilla[prop] || prop);
28 } else {
29 return _Declaration.prototype.prefixed.call(this, prop, prefix);
30 }
31 };
32
33 /**
34 * Return unprefixed version of property
35 */
36
37
38 BorderRadius.prototype.normalize = function normalize(prop) {
39 return BorderRadius.toNormal[prop] || prop;
40 };
41
42 return BorderRadius;
43 }(Declaration);
44
45 Object.defineProperty(BorderRadius, 'names', {
46 enumerable: true,
47 writable: true,
48 value: ['border-radius']
49 });
50 Object.defineProperty(BorderRadius, 'toMozilla', {
51 enumerable: true,
52 writable: true,
53 value: {}
54 });
55 Object.defineProperty(BorderRadius, 'toNormal', {
56 enumerable: true,
57 writable: true,
58 value: {}
59 });
60 var _arr = ['top', 'bottom'];
61
62
63 for (var _i = 0; _i < _arr.length; _i++) {
64 var ver = _arr[_i];var _arr2 = ['left', 'right'];
65
66 for (var _i2 = 0; _i2 < _arr2.length; _i2++) {
67 var hor = _arr2[_i2];
68 var normal = 'border-' + ver + '-' + hor + '-radius';
69 var mozilla = 'border-radius-' + ver + hor;
70
71 BorderRadius.names.push(normal);
72 BorderRadius.names.push(mozilla);
73
74 BorderRadius.toMozilla[normal] = mozilla;
75 BorderRadius.toNormal[mozilla] = normal;
76 }
77 }
78
79 module.exports = BorderRadius;
...\ No newline at end of file ...\ No newline at end of file
1 'use strict';
2
3 function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }
4
5 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
7 function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
8
9 function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : _defaults(subClass, superClass); }
10
11 var Declaration = require('../declaration');
12
13 var BreakProps = function (_Declaration) {
14 _inherits(BreakProps, _Declaration);
15
16 function BreakProps() {
17 _classCallCheck(this, BreakProps);
18
19 return _possibleConstructorReturn(this, _Declaration.apply(this, arguments));
20 }
21
22 /**
23 * Change name for -webkit- and -moz- prefix
24 */
25 BreakProps.prototype.prefixed = function prefixed(prop, prefix) {
26 if (prefix === '-moz-') {
27 return 'page-' + prop;
28 } else {
29 return prefix + 'column-' + prop;
30 }
31 };
32
33 /**
34 * Return property name by final spec
35 */
36
37
38 BreakProps.prototype.normalize = function normalize(prop) {
39 if (prop.indexOf('inside') !== -1) {
40 return 'break-inside';
41 } else if (prop.indexOf('before') !== -1) {
42 return 'break-before';
43 } else {
44 return 'break-after';
45 }
46 };
47
48 /**
49 * Change prefixed value for avoid-column and avoid-page
50 */
51
52
53 BreakProps.prototype.set = function set(decl, prefix) {
54 if (decl.prop === 'break-inside' && decl.value === 'avoid-column' || decl.value === 'avoid-page') {
55 decl.value = 'avoid';
56 }
57 return _Declaration.prototype.set.call(this, decl, prefix);
58 };
59
60 /**
61 * Don’t prefix some values
62 */
63
64
65 BreakProps.prototype.insert = function insert(decl, prefix, prefixes) {
66 if (decl.prop !== 'break-inside') {
67 return _Declaration.prototype.insert.call(this, decl, prefix, prefixes);
68 } else if (decl.value === 'avoid-region') {
69 return undefined;
70 } else if (decl.value === 'avoid-page' && prefix === '-webkit-') {
71 return undefined;
72 } else {
73 return _Declaration.prototype.insert.call(this, decl, prefix, prefixes);
74 }
75 };
76
77 return BreakProps;
78 }(Declaration);
79
80 Object.defineProperty(BreakProps, 'names', {
81 enumerable: true,
82 writable: true,
83 value: ['break-inside', 'page-break-inside', 'column-break-inside', 'break-before', 'page-break-before', 'column-break-before', 'break-after', 'page-break-after', 'column-break-after']
84 });
85
86
87 module.exports = BreakProps;
...\ No newline at end of file ...\ No newline at end of file
1 'use strict';
2
3 function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }
4
5 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
7 function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
8
9 function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : _defaults(subClass, superClass); }
10
11 var Value = require('../value');
12 var list = require('postcss').list;
13
14 var CrossFade = function (_Value) {
15 _inherits(CrossFade, _Value);
16
17 function CrossFade() {
18 _classCallCheck(this, CrossFade);
19
20 return _possibleConstructorReturn(this, _Value.apply(this, arguments));
21 }
22
23 CrossFade.prototype.replace = function replace(string, prefix) {
24 var _this2 = this;
25
26 return list.space(string).map(function (value) {
27 if (value.slice(0, +_this2.name.length + 1) !== _this2.name + '(') {
28 return value;
29 }
30
31 var close = value.lastIndexOf(')');
32 var after = value.slice(close + 1);
33 var args = value.slice(_this2.name.length + 1, close);
34
35 if (prefix === '-webkit-') {
36 var match = args.match(/\d*.?\d+%?/);
37 if (match) {
38 args = args.slice(match[0].length).trim();
39 args += ', ' + match[0];
40 } else {
41 args += ', 0.5';
42 }
43 }
44 return prefix + _this2.name + '(' + args + ')' + after;
45 }).join(' ');
46 };
47
48 return CrossFade;
49 }(Value);
50
51 Object.defineProperty(CrossFade, 'names', {
52 enumerable: true,
53 writable: true,
54 value: ['cross-fade']
55 });
56
57
58 module.exports = CrossFade;
...\ No newline at end of file ...\ No newline at end of file
1 'use strict';
2
3 function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }
4
5 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
7 function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
8
9 function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : _defaults(subClass, superClass); }
10
11 var flexSpec = require('./flex-spec');
12 var OldValue = require('../old-value');
13 var Value = require('../value');
14
15 var DisplayFlex = function (_Value) {
16 _inherits(DisplayFlex, _Value);
17
18 function DisplayFlex(name, prefixes) {
19 _classCallCheck(this, DisplayFlex);
20
21 var _this = _possibleConstructorReturn(this, _Value.call(this, name, prefixes));
22
23 if (name === 'display-flex') {
24 _this.name = 'flex';
25 }
26 return _this;
27 }
28
29 /**
30 * Faster check for flex value
31 */
32
33
34 DisplayFlex.prototype.check = function check(decl) {
35 return decl.prop === 'display' && decl.value === this.name;
36 };
37
38 /**
39 * Return value by spec
40 */
41
42
43 DisplayFlex.prototype.prefixed = function prefixed(prefix) {
44 var spec = void 0,
45 value = void 0;
46
47 var _flexSpec = flexSpec(prefix);
48
49 spec = _flexSpec[0];
50 prefix = _flexSpec[1];
51
52
53 if (spec === 2009) {
54 if (this.name === 'flex') {
55 value = 'box';
56 } else {
57 value = 'inline-box';
58 }
59 } else if (spec === 2012) {
60 if (this.name === 'flex') {
61 value = 'flexbox';
62 } else {
63 value = 'inline-flexbox';
64 }
65 } else if (spec === 'final') {
66 value = this.name;
67 }
68
69 return prefix + value;
70 };
71
72 /**
73 * Add prefix to value depend on flebox spec version
74 */
75
76
77 DisplayFlex.prototype.replace = function replace(string, prefix) {
78 return this.prefixed(prefix);
79 };
80
81 /**
82 * Change value for old specs
83 */
84
85
86 DisplayFlex.prototype.old = function old(prefix) {
87 var prefixed = this.prefixed(prefix);
88 if (!prefixed) return undefined;
89 return new OldValue(this.name, prefixed);
90 };
91
92 return DisplayFlex;
93 }(Value);
94
95 Object.defineProperty(DisplayFlex, 'names', {
96 enumerable: true,
97 writable: true,
98 value: ['display-flex', 'inline-flex']
99 });
100
101
102 module.exports = DisplayFlex;
...\ No newline at end of file ...\ No newline at end of file
1 'use strict';
2
3 function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }
4
5 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
7 function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
8
9 function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : _defaults(subClass, superClass); }
10
11 var Value = require('../value');
12
13 var DisplayGrid = function (_Value) {
14 _inherits(DisplayGrid, _Value);
15
16 function DisplayGrid(name, prefixes) {
17 _classCallCheck(this, DisplayGrid);
18
19 var _this = _possibleConstructorReturn(this, _Value.call(this, name, prefixes));
20
21 if (name === 'display-grid') {
22 _this.name = 'grid';
23 }
24 return _this;
25 }
26
27 /**
28 * Faster check for flex value
29 */
30
31
32 DisplayGrid.prototype.check = function check(decl) {
33 return decl.prop === 'display' && decl.value === this.name;
34 };
35
36 return DisplayGrid;
37 }(Value);
38
39 Object.defineProperty(DisplayGrid, 'names', {
40 enumerable: true,
41 writable: true,
42 value: ['display-grid', 'inline-grid']
43 });
44
45
46 module.exports = DisplayGrid;
...\ No newline at end of file ...\ No newline at end of file
1 'use strict';
2
3 function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }
4
5 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
7 function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
8
9 function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : _defaults(subClass, superClass); }
10
11 var Value = require('../value');
12
13 var FilterValue = function (_Value) {
14 _inherits(FilterValue, _Value);
15
16 function FilterValue(name, prefixes) {
17 _classCallCheck(this, FilterValue);
18
19 var _this = _possibleConstructorReturn(this, _Value.call(this, name, prefixes));
20
21 if (name === 'filter-function') {
22 _this.name = 'filter';
23 }
24 return _this;
25 }
26
27 return FilterValue;
28 }(Value);
29
30 Object.defineProperty(FilterValue, 'names', {
31 enumerable: true,
32 writable: true,
33 value: ['filter', 'filter-function']
34 });
35
36
37 module.exports = FilterValue;
...\ No newline at end of file ...\ No newline at end of file
1 'use strict';
2
3 function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }
4
5 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
7 function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
8
9 function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : _defaults(subClass, superClass); }
10
11 var Declaration = require('../declaration');
12
13 var Filter = function (_Declaration) {
14 _inherits(Filter, _Declaration);
15
16 function Filter() {
17 _classCallCheck(this, Filter);
18
19 return _possibleConstructorReturn(this, _Declaration.apply(this, arguments));
20 }
21
22 /**
23 * Check is it Internet Explorer filter
24 */
25 Filter.prototype.check = function check(decl) {
26 var v = decl.value;
27 return v.toLowerCase().indexOf('alpha(') === -1 && v.indexOf('DXImageTransform.Microsoft') === -1 && v.indexOf('data:image/svg+xml') === -1;
28 };
29
30 return Filter;
31 }(Declaration);
32
33 Object.defineProperty(Filter, 'names', {
34 enumerable: true,
35 writable: true,
36 value: ['filter']
37 });
38
39
40 module.exports = Filter;
...\ No newline at end of file ...\ No newline at end of file
1 'use strict';
2
3 function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }
4
5 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
7 function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
8
9 function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : _defaults(subClass, superClass); }
10
11 var flexSpec = require('./flex-spec');
12 var Declaration = require('../declaration');
13
14 var FlexBasis = function (_Declaration) {
15 _inherits(FlexBasis, _Declaration);
16
17 function FlexBasis() {
18 _classCallCheck(this, FlexBasis);
19
20 return _possibleConstructorReturn(this, _Declaration.apply(this, arguments));
21 }
22
23 /**
24 * Return property name by final spec
25 */
26 FlexBasis.prototype.normalize = function normalize() {
27 return 'flex-basis';
28 };
29
30 /**
31 * Return flex property for 2012 spec
32 */
33
34
35 FlexBasis.prototype.prefixed = function prefixed(prop, prefix) {
36 var spec = void 0;
37
38 var _flexSpec = flexSpec(prefix);
39
40 spec = _flexSpec[0];
41 prefix = _flexSpec[1];
42
43 if (spec === 2012) {
44 return prefix + 'flex-preferred-size';
45 } else {
46 return _Declaration.prototype.prefixed.call(this, prop, prefix);
47 }
48 };
49
50 /**
51 * Ignore 2009 spec and use flex property for 2012
52 */
53
54
55 FlexBasis.prototype.set = function set(decl, prefix) {
56 var spec = void 0;
57
58 var _flexSpec2 = flexSpec(prefix);
59
60 spec = _flexSpec2[0];
61 prefix = _flexSpec2[1];
62
63 if (spec === 2012 || spec === 'final') {
64 return _Declaration.prototype.set.call(this, decl, prefix);
65 }
66 return undefined;
67 };
68
69 return FlexBasis;
70 }(Declaration);
71
72 Object.defineProperty(FlexBasis, 'names', {
73 enumerable: true,
74 writable: true,
75 value: ['flex-basis', 'flex-preferred-size']
76 });
77
78
79 module.exports = FlexBasis;
...\ No newline at end of file ...\ No newline at end of file
1 'use strict';
2
3 function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }
4
5 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
7 function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
8
9 function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : _defaults(subClass, superClass); }
10
11 var flexSpec = require('./flex-spec');
12 var Declaration = require('../declaration');
13
14 var FlexDirection = function (_Declaration) {
15 _inherits(FlexDirection, _Declaration);
16
17 function FlexDirection() {
18 _classCallCheck(this, FlexDirection);
19
20 return _possibleConstructorReturn(this, _Declaration.apply(this, arguments));
21 }
22
23 /**
24 * Return property name by final spec
25 */
26 FlexDirection.prototype.normalize = function normalize() {
27 return 'flex-direction';
28 };
29
30 /**
31 * Use two properties for 2009 spec
32 */
33
34
35 FlexDirection.prototype.insert = function insert(decl, prefix, prefixes) {
36 var spec = void 0;
37
38 var _flexSpec = flexSpec(prefix);
39
40 spec = _flexSpec[0];
41 prefix = _flexSpec[1];
42
43 if (spec !== 2009) {
44 return _Declaration.prototype.insert.call(this, decl, prefix, prefixes);
45 } else {
46 var already = decl.parent.some(function (i) {
47 return i.prop === prefix + 'box-orient' || i.prop === prefix + 'box-direction';
48 });
49 if (already) {
50 return undefined;
51 }
52
53 var v = decl.value;
54 var orient = void 0,
55 dir = void 0;
56 if (v === 'inherit' || v === 'initial' || v === 'unset') {
57 orient = v;
58 dir = v;
59 } else {
60 orient = v.indexOf('row') !== -1 ? 'horizontal' : 'vertical';
61 dir = v.indexOf('reverse') !== -1 ? 'reverse' : 'normal';
62 }
63
64 var cloned = this.clone(decl);
65 cloned.prop = prefix + 'box-orient';
66 cloned.value = orient;
67 if (this.needCascade(decl)) {
68 cloned.raws.before = this.calcBefore(prefixes, decl, prefix);
69 }
70 decl.parent.insertBefore(decl, cloned);
71
72 cloned = this.clone(decl);
73 cloned.prop = prefix + 'box-direction';
74 cloned.value = dir;
75 if (this.needCascade(decl)) {
76 cloned.raws.before = this.calcBefore(prefixes, decl, prefix);
77 }
78 return decl.parent.insertBefore(decl, cloned);
79 }
80 };
81
82 /**
83 * Clean two properties for 2009 spec
84 */
85
86
87 FlexDirection.prototype.old = function old(prop, prefix) {
88 var spec = void 0;
89
90 var _flexSpec2 = flexSpec(prefix);
91
92 spec = _flexSpec2[0];
93 prefix = _flexSpec2[1];
94
95 if (spec === 2009) {
96 return [prefix + 'box-orient', prefix + 'box-direction'];
97 } else {
98 return _Declaration.prototype.old.call(this, prop, prefix);
99 }
100 };
101
102 return FlexDirection;
103 }(Declaration);
104
105 Object.defineProperty(FlexDirection, 'names', {
106 enumerable: true,
107 writable: true,
108 value: ['flex-direction', 'box-direction', 'box-orient']
109 });
110
111
112 module.exports = FlexDirection;
...\ No newline at end of file ...\ No newline at end of file
1 'use strict';
2
3 function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }
4
5 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
7 function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
8
9 function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : _defaults(subClass, superClass); }
10
11 var flexSpec = require('./flex-spec');
12 var Declaration = require('../declaration');
13
14 var FlexFlow = function (_Declaration) {
15 _inherits(FlexFlow, _Declaration);
16
17 function FlexFlow() {
18 _classCallCheck(this, FlexFlow);
19
20 return _possibleConstructorReturn(this, _Declaration.apply(this, arguments));
21 }
22
23 /**
24 * Use two properties for 2009 spec
25 */
26 FlexFlow.prototype.insert = function insert(decl, prefix, prefixes) {
27 var spec = void 0;
28
29 var _flexSpec = flexSpec(prefix);
30
31 spec = _flexSpec[0];
32 prefix = _flexSpec[1];
33
34 if (spec !== 2009) {
35 return _Declaration.prototype.insert.call(this, decl, prefix, prefixes);
36 } else {
37 var values = decl.value.split(/\s+/).filter(function (i) {
38 return i !== 'wrap' && i !== 'nowrap' && 'wrap-reverse';
39 });
40 if (values.length === 0) {
41 return undefined;
42 }
43
44 var already = decl.parent.some(function (i) {
45 return i.prop === prefix + 'box-orient' || i.prop === prefix + 'box-direction';
46 });
47 if (already) {
48 return undefined;
49 }
50
51 var value = values[0];
52 var orient = value.indexOf('row') !== -1 ? 'horizontal' : 'vertical';
53 var dir = value.indexOf('reverse') !== -1 ? 'reverse' : 'normal';
54
55 var cloned = this.clone(decl);
56 cloned.prop = prefix + 'box-orient';
57 cloned.value = orient;
58 if (this.needCascade(decl)) {
59 cloned.raws.before = this.calcBefore(prefixes, decl, prefix);
60 }
61 decl.parent.insertBefore(decl, cloned);
62
63 cloned = this.clone(decl);
64 cloned.prop = prefix + 'box-direction';
65 cloned.value = dir;
66 if (this.needCascade(decl)) {
67 cloned.raws.before = this.calcBefore(prefixes, decl, prefix);
68 }
69 return decl.parent.insertBefore(decl, cloned);
70 }
71 };
72
73 return FlexFlow;
74 }(Declaration);
75
76 Object.defineProperty(FlexFlow, 'names', {
77 enumerable: true,
78 writable: true,
79 value: ['flex-flow', 'box-direction', 'box-orient']
80 });
81
82
83 module.exports = FlexFlow;
...\ No newline at end of file ...\ No newline at end of file
1 'use strict';
2
3 function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }
4
5 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
7 function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
8
9 function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : _defaults(subClass, superClass); }
10
11 var flexSpec = require('./flex-spec');
12 var Declaration = require('../declaration');
13
14 var Flex = function (_Declaration) {
15 _inherits(Flex, _Declaration);
16
17 function Flex() {
18 _classCallCheck(this, Flex);
19
20 return _possibleConstructorReturn(this, _Declaration.apply(this, arguments));
21 }
22
23 /**
24 * Return property name by final spec
25 */
26 Flex.prototype.normalize = function normalize() {
27 return 'flex';
28 };
29
30 /**
31 * Return flex property for 2009 and 2012 specs
32 */
33
34
35 Flex.prototype.prefixed = function prefixed(prop, prefix) {
36 var spec = void 0;
37
38 var _flexSpec = flexSpec(prefix);
39
40 spec = _flexSpec[0];
41 prefix = _flexSpec[1];
42
43 if (spec === 2009) {
44 return prefix + 'box-flex';
45 } else if (spec === 2012) {
46 return prefix + 'flex-positive';
47 } else {
48 return _Declaration.prototype.prefixed.call(this, prop, prefix);
49 }
50 };
51
52 return Flex;
53 }(Declaration);
54
55 Object.defineProperty(Flex, 'names', {
56 enumerable: true,
57 writable: true,
58 value: ['flex-grow', 'flex-positive']
59 });
60
61
62 module.exports = Flex;
...\ No newline at end of file ...\ No newline at end of file
1 'use strict';
2
3 function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }
4
5 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
7 function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
8
9 function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : _defaults(subClass, superClass); }
10
11 var flexSpec = require('./flex-spec');
12 var Declaration = require('../declaration');
13
14 var FlexShrink = function (_Declaration) {
15 _inherits(FlexShrink, _Declaration);
16
17 function FlexShrink() {
18 _classCallCheck(this, FlexShrink);
19
20 return _possibleConstructorReturn(this, _Declaration.apply(this, arguments));
21 }
22
23 /**
24 * Return property name by final spec
25 */
26 FlexShrink.prototype.normalize = function normalize() {
27 return 'flex-shrink';
28 };
29
30 /**
31 * Return flex property for 2012 spec
32 */
33
34
35 FlexShrink.prototype.prefixed = function prefixed(prop, prefix) {
36 var spec = void 0;
37
38 var _flexSpec = flexSpec(prefix);
39
40 spec = _flexSpec[0];
41 prefix = _flexSpec[1];
42
43 if (spec === 2012) {
44 return prefix + 'flex-negative';
45 } else {
46 return _Declaration.prototype.prefixed.call(this, prop, prefix);
47 }
48 };
49
50 /**
51 * Ignore 2009 spec and use flex property for 2012
52 */
53
54
55 FlexShrink.prototype.set = function set(decl, prefix) {
56 var spec = void 0;
57
58 var _flexSpec2 = flexSpec(prefix);
59
60 spec = _flexSpec2[0];
61 prefix = _flexSpec2[1];
62
63 if (spec === 2012 || spec === 'final') {
64 return _Declaration.prototype.set.call(this, decl, prefix);
65 }
66 return undefined;
67 };
68
69 return FlexShrink;
70 }(Declaration);
71
72 Object.defineProperty(FlexShrink, 'names', {
73 enumerable: true,
74 writable: true,
75 value: ['flex-shrink', 'flex-negative']
76 });
77
78
79 module.exports = FlexShrink;
...\ No newline at end of file ...\ No newline at end of file
1 'use strict';
2
3 /**
4 * Return flexbox spec versions by prefix
5 */
6 module.exports = function (prefix) {
7 var spec = void 0;
8 if (prefix === '-webkit- 2009' || prefix === '-moz-') {
9 spec = 2009;
10 } else if (prefix === '-ms-') {
11 spec = 2012;
12 } else if (prefix === '-webkit-') {
13 spec = 'final';
14 }
15
16 if (prefix === '-webkit- 2009') {
17 prefix = '-webkit-';
18 }
19
20 return [spec, prefix];
21 };
...\ No newline at end of file ...\ No newline at end of file
1 'use strict';
2
3 function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }
4
5 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
7 function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
8
9 function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : _defaults(subClass, superClass); }
10
11 var flexSpec = require('./flex-spec');
12 var Declaration = require('../declaration');
13
14 var FlexWrap = function (_Declaration) {
15 _inherits(FlexWrap, _Declaration);
16
17 function FlexWrap() {
18 _classCallCheck(this, FlexWrap);
19
20 return _possibleConstructorReturn(this, _Declaration.apply(this, arguments));
21 }
22
23 /**
24 * Don't add prefix for 2009 spec
25 */
26 FlexWrap.prototype.set = function set(decl, prefix) {
27 var spec = flexSpec(prefix)[0];
28 if (spec !== 2009) {
29 return _Declaration.prototype.set.call(this, decl, prefix);
30 }
31 return undefined;
32 };
33
34 return FlexWrap;
35 }(Declaration);
36
37 Object.defineProperty(FlexWrap, 'names', {
38 enumerable: true,
39 writable: true,
40 value: ['flex-wrap']
41 });
42
43
44 module.exports = FlexWrap;
...\ No newline at end of file ...\ No newline at end of file
1 'use strict';
2
3 function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }
4
5 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
7 function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
8
9 function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : _defaults(subClass, superClass); }
10
11 var flexSpec = require('./flex-spec');
12 var Declaration = require('../declaration');
13
14 var list = require('postcss').list;
15
16 var Flex = function (_Declaration) {
17 _inherits(Flex, _Declaration);
18
19 function Flex() {
20 _classCallCheck(this, Flex);
21
22 return _possibleConstructorReturn(this, _Declaration.apply(this, arguments));
23 }
24
25 /**
26 * Change property name for 2009 spec
27 */
28 Flex.prototype.prefixed = function prefixed(prop, prefix) {
29 var spec = void 0;
30
31 var _flexSpec = flexSpec(prefix);
32
33 spec = _flexSpec[0];
34 prefix = _flexSpec[1];
35
36 if (spec === 2009) {
37 return prefix + 'box-flex';
38 } else {
39 return _Declaration.prototype.prefixed.call(this, prop, prefix);
40 }
41 };
42
43 /**
44 * Return property name by final spec
45 */
46
47
48 Flex.prototype.normalize = function normalize() {
49 return 'flex';
50 };
51
52 /**
53 * Spec 2009 supports only first argument
54 * Spec 2012 disallows unitless basis
55 */
56
57
58 Flex.prototype.set = function set(decl, prefix) {
59 var spec = flexSpec(prefix)[0];
60 if (spec === 2009) {
61 decl.value = list.space(decl.value)[0];
62 decl.value = Flex.oldValues[decl.value] || decl.value;
63 return _Declaration.prototype.set.call(this, decl, prefix);
64 } else if (spec === 2012) {
65 var components = list.space(decl.value);
66 if (components.length === 3 && components[2] === '0') {
67 decl.value = components.slice(0, 2).concat('0px').join(' ');
68 }
69 }
70 return _Declaration.prototype.set.call(this, decl, prefix);
71 };
72
73 return Flex;
74 }(Declaration);
75
76 Object.defineProperty(Flex, 'names', {
77 enumerable: true,
78 writable: true,
79 value: ['flex', 'box-flex']
80 });
81 Object.defineProperty(Flex, 'oldValues', {
82 enumerable: true,
83 writable: true,
84 value: {
85 auto: '1',
86 none: '0'
87 }
88 });
89
90
91 module.exports = Flex;
...\ No newline at end of file ...\ No newline at end of file
1 'use strict';
2
3 function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }
4
5 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
7 function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
8
9 function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : _defaults(subClass, superClass); }
10
11 var Selector = require('../selector');
12
13 var Fullscreen = function (_Selector) {
14 _inherits(Fullscreen, _Selector);
15
16 function Fullscreen() {
17 _classCallCheck(this, Fullscreen);
18
19 return _possibleConstructorReturn(this, _Selector.apply(this, arguments));
20 }
21
22 /**
23 * Return different selectors depend on prefix
24 */
25 Fullscreen.prototype.prefixed = function prefixed(prefix) {
26 if (prefix === '-webkit-') {
27 return ':-webkit-full-screen';
28 } else if (prefix === '-moz-') {
29 return ':-moz-full-screen';
30 } else {
31 return ':' + prefix + 'fullscreen';
32 }
33 };
34
35 return Fullscreen;
36 }(Selector);
37
38 Object.defineProperty(Fullscreen, 'names', {
39 enumerable: true,
40 writable: true,
41 value: [':fullscreen']
42 });
43
44
45 module.exports = Fullscreen;
...\ No newline at end of file ...\ No newline at end of file
1 'use strict';
2
3 function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }
4
5 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
7 function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
8
9 function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : _defaults(subClass, superClass); }
10
11 var Declaration = require('../declaration');
12 var shorthand = require('./grid-shorthand');
13
14 var GridArea = function (_Declaration) {
15 _inherits(GridArea, _Declaration);
16
17 function GridArea() {
18 _classCallCheck(this, GridArea);
19
20 return _possibleConstructorReturn(this, _Declaration.apply(this, arguments));
21 }
22
23 /**
24 * Translate grid-area to separate -ms- prefixed properties
25 */
26 GridArea.prototype.insert = function insert(decl, prefix, prefixes) {
27 if (prefix !== '-ms-') return _Declaration.prototype.insert.call(this, decl, prefix, prefixes);
28
29 if (decl.parent.some(function (i) {
30 return i.prop === '-ms-grid-row';
31 })) {
32 return undefined;
33 }
34
35 var values = shorthand.parse(decl);
36
37 var _shorthand$translate = shorthand.translate(values, 0, 2),
38 rowStart = _shorthand$translate[0],
39 rowSpan = _shorthand$translate[1];
40
41 var _shorthand$translate2 = shorthand.translate(values, 1, 3),
42 columnStart = _shorthand$translate2[0],
43 columnSpan = _shorthand$translate2[1];
44
45 if (rowStart) {
46 decl.cloneBefore({
47 prop: '-ms-grid-row',
48 value: rowStart.toString()
49 });
50 }
51
52 if (rowSpan) {
53 decl.cloneBefore({
54 prop: '-ms-grid-row-span',
55 value: rowSpan.toString()
56 });
57 }
58
59 if (columnStart) {
60 decl.cloneBefore({
61 prop: '-ms-grid-column',
62 value: columnStart.toString()
63 });
64 }
65
66 if (columnSpan) {
67 decl.cloneBefore({
68 prop: '-ms-grid-column-span',
69 value: columnSpan.toString()
70 });
71 }
72
73 return undefined;
74 };
75
76 return GridArea;
77 }(Declaration);
78
79 Object.defineProperty(GridArea, 'names', {
80 enumerable: true,
81 writable: true,
82 value: ['grid-area']
83 });
84
85
86 module.exports = GridArea;
...\ No newline at end of file ...\ No newline at end of file
1 'use strict';
2
3 function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }
4
5 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
7 function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
8
9 function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : _defaults(subClass, superClass); }
10
11 var Declaration = require('../declaration');
12
13 var GridColumnAlign = function (_Declaration) {
14 _inherits(GridColumnAlign, _Declaration);
15
16 function GridColumnAlign() {
17 _classCallCheck(this, GridColumnAlign);
18
19 return _possibleConstructorReturn(this, _Declaration.apply(this, arguments));
20 }
21
22 /**
23 * Do not prefix flexbox values
24 */
25 GridColumnAlign.prototype.check = function check(decl) {
26 return decl.value.indexOf('flex-') === -1 && decl.value !== 'baseline';
27 };
28
29 /**
30 * Change property name for IE
31 */
32
33
34 GridColumnAlign.prototype.prefixed = function prefixed(prop, prefix) {
35 return prefix + 'grid-column-align';
36 };
37
38 /**
39 * Change IE property back
40 */
41
42
43 GridColumnAlign.prototype.normalize = function normalize() {
44 return 'justify-self';
45 };
46
47 return GridColumnAlign;
48 }(Declaration);
49
50 Object.defineProperty(GridColumnAlign, 'names', {
51 enumerable: true,
52 writable: true,
53 value: ['grid-column-align']
54 });
55
56
57 module.exports = GridColumnAlign;
...\ No newline at end of file ...\ No newline at end of file
1 'use strict';
2
3 function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }
4
5 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
7 function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
8
9 function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : _defaults(subClass, superClass); }
10
11 var Declaration = require('../declaration');
12
13 var GridEnd = function (_Declaration) {
14 _inherits(GridEnd, _Declaration);
15
16 function GridEnd() {
17 _classCallCheck(this, GridEnd);
18
19 return _possibleConstructorReturn(this, _Declaration.apply(this, arguments));
20 }
21
22 /**
23 * Do not add prefix for unsupported value in IE
24 */
25 GridEnd.prototype.check = function check(decl) {
26 return decl.value.indexOf('span') !== -1;
27 };
28
29 /**
30 * Return a final spec property
31 */
32
33
34 GridEnd.prototype.normalize = function normalize(prop) {
35 return prop.replace(/(-span|-end)/, '');
36 };
37
38 /**
39 * Change property name for IE
40 */
41
42
43 GridEnd.prototype.prefixed = function prefixed(prop, prefix) {
44 var result = _Declaration.prototype.prefixed.call(this, prop, prefix);
45 if (prefix === '-ms-') {
46 result = result.replace('-end', '-span');
47 }
48 return result;
49 };
50
51 /**
52 * Change repeating syntax for IE
53 */
54
55
56 GridEnd.prototype.set = function set(decl, prefix) {
57 if (prefix === '-ms-') {
58 decl.value = decl.value.replace(/span\s/i, '');
59 }
60 return _Declaration.prototype.set.call(this, decl, prefix);
61 };
62
63 return GridEnd;
64 }(Declaration);
65
66 Object.defineProperty(GridEnd, 'names', {
67 enumerable: true,
68 writable: true,
69 value: ['grid-row-end', 'grid-column-end', 'grid-row-span', 'grid-column-span']
70 });
71
72
73 module.exports = GridEnd;
...\ No newline at end of file ...\ No newline at end of file
1 'use strict';
2
3 function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }
4
5 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
7 function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
8
9 function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : _defaults(subClass, superClass); }
10
11 var Declaration = require('../declaration');
12
13 var GridRowAlign = function (_Declaration) {
14 _inherits(GridRowAlign, _Declaration);
15
16 function GridRowAlign() {
17 _classCallCheck(this, GridRowAlign);
18
19 return _possibleConstructorReturn(this, _Declaration.apply(this, arguments));
20 }
21
22 /**
23 * Do not prefix flexbox values
24 */
25 GridRowAlign.prototype.check = function check(decl) {
26 return decl.value.indexOf('flex-') === -1 && decl.value !== 'baseline';
27 };
28
29 /**
30 * Change property name for IE
31 */
32
33
34 GridRowAlign.prototype.prefixed = function prefixed(prop, prefix) {
35 return prefix + 'grid-row-align';
36 };
37
38 /**
39 * Change IE property back
40 */
41
42
43 GridRowAlign.prototype.normalize = function normalize() {
44 return 'align-self';
45 };
46
47 return GridRowAlign;
48 }(Declaration);
49
50 Object.defineProperty(GridRowAlign, 'names', {
51 enumerable: true,
52 writable: true,
53 value: ['grid-row-align']
54 });
55
56
57 module.exports = GridRowAlign;
...\ No newline at end of file ...\ No newline at end of file
1 'use strict';
2
3 function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }
4
5 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
7 function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
8
9 function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : _defaults(subClass, superClass); }
10
11 var Declaration = require('../declaration');
12 var shorthand = require('./grid-shorthand');
13
14 var GridRowColumn = function (_Declaration) {
15 _inherits(GridRowColumn, _Declaration);
16
17 function GridRowColumn() {
18 _classCallCheck(this, GridRowColumn);
19
20 return _possibleConstructorReturn(this, _Declaration.apply(this, arguments));
21 }
22
23 /**
24 * Translate grid-row / grid-column to separate -ms- prefixed properties
25 */
26 GridRowColumn.prototype.insert = function insert(decl, prefix, prefixes) {
27 if (prefix !== '-ms-') return _Declaration.prototype.insert.call(this, decl, prefix, prefixes);
28
29 var values = shorthand.parse(decl);
30
31 var _shorthand$translate = shorthand.translate(values, 0, 1),
32 start = _shorthand$translate[0],
33 span = _shorthand$translate[1];
34
35 if (start) {
36 decl.cloneBefore({
37 prop: '-ms-' + decl.prop,
38 value: start.toString()
39 });
40 }
41
42 if (span) {
43 decl.cloneBefore({
44 prop: '-ms-' + decl.prop + '-span',
45 value: span.toString()
46 });
47 }
48
49 return undefined;
50 };
51
52 return GridRowColumn;
53 }(Declaration);
54
55 Object.defineProperty(GridRowColumn, 'names', {
56 enumerable: true,
57 writable: true,
58 value: ['grid-row', 'grid-column']
59 });
60
61
62 module.exports = GridRowColumn;
...\ No newline at end of file ...\ No newline at end of file
1 'use strict';
2
3 function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }
4
5 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
7 function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
8
9 function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : _defaults(subClass, superClass); }
10
11 var Declaration = require('../declaration');
12 var shorthand = require('./grid-shorthand');
13
14 var GridRowsColumns = function (_Declaration) {
15 _inherits(GridRowsColumns, _Declaration);
16
17 function GridRowsColumns() {
18 _classCallCheck(this, GridRowsColumns);
19
20 return _possibleConstructorReturn(this, _Declaration.apply(this, arguments));
21 }
22
23 /**
24 * Change property name for IE
25 */
26 GridRowsColumns.prototype.prefixed = function prefixed(prop, prefix) {
27 if (prefix === '-ms-') {
28 return prefix + prop.replace('template-', '');
29 } else {
30 return _Declaration.prototype.prefixed.call(this, prop, prefix);
31 }
32 };
33
34 /**
35 * Change IE property back
36 */
37
38
39 GridRowsColumns.prototype.normalize = function normalize(prop) {
40 return prop.replace(/^grid-(rows|columns)/, 'grid-template-$1');
41 };
42
43 /**
44 * Change repeating syntax for IE
45 */
46
47
48 GridRowsColumns.prototype.set = function set(decl, prefix) {
49 if (prefix === '-ms-' && decl.value.indexOf('repeat(') !== -1) {
50 decl.value = shorthand.changeRepeat(decl.value);
51 }
52 return _Declaration.prototype.set.call(this, decl, prefix);
53 };
54
55 return GridRowsColumns;
56 }(Declaration);
57
58 Object.defineProperty(GridRowsColumns, 'names', {
59 enumerable: true,
60 writable: true,
61 value: ['grid-template-rows', 'grid-template-columns', 'grid-rows', 'grid-columns']
62 });
63
64
65 module.exports = GridRowsColumns;
...\ No newline at end of file ...\ No newline at end of file
1 'use strict';
2
3 var parser = require('postcss-value-parser');
4
5 function convert(value) {
6 if (value && value.length === 2 && value[0] === 'span' && parseInt(value[1], 10) > 0) {
7 return [false, parseInt(value[1], 10)];
8 }
9
10 if (value && value.length === 1 && parseInt(value[0], 10) > 0) {
11 return [parseInt(value[0], 10), false];
12 }
13
14 return [false, false];
15 }
16
17 function translate(values, startIndex, endIndex) {
18 var startValue = values[startIndex];
19 var endValue = values[endIndex];
20
21 if (!startValue) {
22 return [false, false];
23 }
24
25 var _convert = convert(startValue),
26 start = _convert[0],
27 spanStart = _convert[1];
28
29 var _convert2 = convert(endValue),
30 end = _convert2[0],
31 spanEnd = _convert2[1];
32
33 if (start && !endValue) {
34 return [start, false];
35 }
36
37 if (spanStart && end) {
38 return [end - spanStart, spanStart];
39 }
40
41 if (start && spanEnd) {
42 return [start, spanEnd];
43 }
44
45 if (start && end) {
46 return [start, end - start];
47 }
48
49 return [false, false];
50 }
51
52 function parse(decl) {
53 var node = parser(decl.value);
54
55 var values = [];
56 var current = 0;
57 values[current] = [];
58
59 for (var _iterator = node.nodes, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
60 var _ref;
61
62 if (_isArray) {
63 if (_i >= _iterator.length) break;
64 _ref = _iterator[_i++];
65 } else {
66 _i = _iterator.next();
67 if (_i.done) break;
68 _ref = _i.value;
69 }
70
71 var i = _ref;
72
73 if (i.type === 'div') {
74 current += 1;
75 values[current] = [];
76 } else if (i.type === 'word') {
77 values[current].push(i.value);
78 }
79 }
80
81 return values;
82 }
83
84 function parseTemplateShortcut(decl) {
85 var node = parser(decl.value, { loose: true });
86
87 var values = [];
88 var current = 0;
89 values[current] = [];
90
91 for (var _iterator2 = node.nodes, _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : _iterator2[Symbol.iterator]();;) {
92 var _ref2;
93
94 if (_isArray2) {
95 if (_i2 >= _iterator2.length) break;
96 _ref2 = _iterator2[_i2++];
97 } else {
98 _i2 = _iterator2.next();
99 if (_i2.done) break;
100 _ref2 = _i2.value;
101 }
102
103 var i = _ref2;
104
105 if (i.type === 'div') {
106 current += 1;
107 values[current] = [];
108 } else {
109 values[current].push(parser.stringify(i));
110 }
111 }
112
113 return values;
114 }
115
116 function walkRepeat(node) {
117 var fixed = [];
118 for (var _iterator3 = node.nodes, _isArray3 = Array.isArray(_iterator3), _i3 = 0, _iterator3 = _isArray3 ? _iterator3 : _iterator3[Symbol.iterator]();;) {
119 var _ref3;
120
121 if (_isArray3) {
122 if (_i3 >= _iterator3.length) break;
123 _ref3 = _iterator3[_i3++];
124 } else {
125 _i3 = _iterator3.next();
126 if (_i3.done) break;
127 _ref3 = _i3.value;
128 }
129
130 var i = _ref3;
131
132 if (i.nodes) {
133 walkRepeat(i);
134 }
135 fixed.push(i);
136 if (i.type === 'function' && i.value === 'repeat') {
137 var first = i.nodes.shift();
138 if (first) {
139 var count = first.value;
140 i.nodes.shift();
141 i.value = '';
142 fixed.push({ type: 'word', value: '[' + count + ']' });
143 }
144 }
145 }
146 node.nodes = fixed;
147 }
148
149 function changeRepeat(value) {
150 var ast = parser(value);
151 walkRepeat(ast);
152 return ast.toString();
153 }
154
155 module.exports = {
156 parse: parse,
157 translate: translate,
158 changeRepeat: changeRepeat,
159 parseTemplateShortcut: parseTemplateShortcut
160 };
...\ No newline at end of file ...\ No newline at end of file
1 'use strict';
2
3 function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }
4
5 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
7 function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
8
9 function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : _defaults(subClass, superClass); }
10
11 var Declaration = require('../declaration');
12
13 var GridStart = function (_Declaration) {
14 _inherits(GridStart, _Declaration);
15
16 function GridStart() {
17 _classCallCheck(this, GridStart);
18
19 return _possibleConstructorReturn(this, _Declaration.apply(this, arguments));
20 }
21
22 /**
23 * Do not add prefix for unsupported value in IE
24 */
25 GridStart.prototype.check = function check(decl) {
26 var value = decl.value;
27 return value.indexOf('/') === -1 || value.indexOf('span') !== -1;
28 };
29
30 /**
31 * Return a final spec property
32 */
33
34
35 GridStart.prototype.normalize = function normalize(prop) {
36 return prop.replace('-start', '');
37 };
38
39 /**
40 * Change property name for IE
41 */
42
43
44 GridStart.prototype.prefixed = function prefixed(prop, prefix) {
45 var result = _Declaration.prototype.prefixed.call(this, prop, prefix);
46 if (prefix === '-ms-') {
47 result = result.replace('-start', '');
48 }
49 return result;
50 };
51
52 return GridStart;
53 }(Declaration);
54
55 Object.defineProperty(GridStart, 'names', {
56 enumerable: true,
57 writable: true,
58 value: ['grid-row-start', 'grid-column-start']
59 });
60
61
62 module.exports = GridStart;
...\ No newline at end of file ...\ No newline at end of file
1 'use strict';
2
3 function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }
4
5 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
7 function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
8
9 function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : _defaults(subClass, superClass); }
10
11 var Declaration = require('../declaration');
12
13 var DOTS = /^\.+$/;
14
15 function track(start, end) {
16 return { start: start, end: end, span: end - start };
17 }
18
19 function getRows(tpl) {
20 return tpl.trim().slice(1, -1).split(/['"]\s*['"]?/g);
21 }
22
23 function getColumns(line) {
24 return line.trim().split(/\s+/g);
25 }
26
27 function parseGridAreas(tpl) {
28 return getRows(tpl).reduce(function (areas, line, rowIndex) {
29 if (line.trim() === '') return areas;
30 getColumns(line).forEach(function (area, columnIndex) {
31 if (DOTS.test(area)) return;
32 if (typeof areas[area] === 'undefined') {
33 areas[area] = {
34 column: track(columnIndex + 1, columnIndex + 2),
35 row: track(rowIndex + 1, rowIndex + 2)
36 };
37 } else {
38 var _areas$area = areas[area],
39 column = _areas$area.column,
40 row = _areas$area.row;
41
42
43 column.start = Math.min(column.start, columnIndex + 1);
44 column.end = Math.max(column.end, columnIndex + 2);
45 column.span = column.end - column.start;
46
47 row.start = Math.min(row.start, rowIndex + 1);
48 row.end = Math.max(row.end, rowIndex + 2);
49 row.span = row.end - row.start;
50 }
51 });
52 return areas;
53 }, {});
54 }
55
56 var GridTemplateAreas = function (_Declaration) {
57 _inherits(GridTemplateAreas, _Declaration);
58
59 function GridTemplateAreas() {
60 _classCallCheck(this, GridTemplateAreas);
61
62 return _possibleConstructorReturn(this, _Declaration.apply(this, arguments));
63 }
64
65 GridTemplateAreas.prototype.getRoot = function getRoot(parent) {
66 if (parent.type === 'atrule' || !parent.parent) {
67 return parent;
68 }
69 return this.getRoot(parent.parent);
70 };
71
72 /**
73 * Translate grid-template-areas to separate -ms- prefixed properties
74 */
75
76
77 GridTemplateAreas.prototype.insert = function insert(decl, prefix, prefixes, result) {
78 if (prefix !== '-ms-') return _Declaration.prototype.insert.call(this, decl, prefix, prefixes);
79
80 var areas = parseGridAreas(decl.value);
81 var missed = Object.keys(areas);
82
83 this.getRoot(decl.parent).walkDecls('grid-area', function (gridArea) {
84 var value = gridArea.value;
85 var area = areas[value];
86
87 missed = missed.filter(function (e) {
88 return e !== value;
89 });
90
91 if (area) {
92 gridArea.parent.walkDecls(/-ms-grid-(row|column)/, function (d) {
93 d.remove();
94 });
95
96 gridArea.cloneBefore({
97 prop: '-ms-grid-row',
98 value: String(area.row.start)
99 });
100 if (area.row.span > 1) {
101 gridArea.cloneBefore({
102 prop: '-ms-grid-row-span',
103 value: String(area.row.span)
104 });
105 }
106 gridArea.cloneBefore({
107 prop: '-ms-grid-column',
108 value: String(area.column.start)
109 });
110 if (area.column.span > 1) {
111 gridArea.cloneBefore({
112 prop: '-ms-grid-column-span',
113 value: String(area.column.span)
114 });
115 }
116 }
117 return undefined;
118 });
119
120 if (missed.length > 0) {
121 decl.warn(result, 'Can not find grid areas: ' + missed.join(', '));
122 }
123
124 return decl;
125 };
126
127 return GridTemplateAreas;
128 }(Declaration);
129
130 Object.defineProperty(GridTemplateAreas, 'names', {
131 enumerable: true,
132 writable: true,
133 value: ['grid-template-areas']
134 });
135
136
137 module.exports = GridTemplateAreas;
...\ No newline at end of file ...\ No newline at end of file
1 'use strict';
2
3 function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }
4
5 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
7 function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
8
9 function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : _defaults(subClass, superClass); }
10
11 var Declaration = require('../declaration');
12 var shorthand = require('./grid-shorthand');
13
14 var GridTemplate = function (_Declaration) {
15 _inherits(GridTemplate, _Declaration);
16
17 function GridTemplate() {
18 _classCallCheck(this, GridTemplate);
19
20 return _possibleConstructorReturn(this, _Declaration.apply(this, arguments));
21 }
22
23 /**
24 * Do not add prefix for unsupported value in IE
25 */
26 GridTemplate.prototype.check = function check(decl) {
27 return decl.value.includes('/') && !decl.value.includes('[') && !decl.value.includes('"') && !decl.value.includes('\'');
28 };
29
30 /**
31 * Translate grid-template to separate -ms- prefixed properties
32 */
33
34
35 GridTemplate.prototype.insert = function insert(decl, prefix, prefixes) {
36 if (prefix !== '-ms-') return _Declaration.prototype.insert.call(this, decl, prefix, prefixes);
37
38 if (decl.parent.some(function (i) {
39 return i.prop === '-ms-grid-rows';
40 })) {
41 return undefined;
42 }
43
44 var _shorthand$parseTempl = shorthand.parseTemplateShortcut(decl),
45 templateRows = _shorthand$parseTempl[0],
46 templateColumns = _shorthand$parseTempl[1];
47
48 if (templateRows) {
49 decl.cloneBefore({
50 prop: '-ms-grid-rows',
51 value: shorthand.changeRepeat(templateRows.join(''))
52 });
53 }
54
55 if (templateColumns) {
56 decl.cloneBefore({
57 prop: '-ms-grid-columns',
58 value: shorthand.changeRepeat(templateColumns.join(''))
59 });
60 }
61
62 return decl;
63 };
64
65 return GridTemplate;
66 }(Declaration);
67
68 Object.defineProperty(GridTemplate, 'names', {
69 enumerable: true,
70 writable: true,
71 value: ['grid-template']
72 });
73
74
75 module.exports = GridTemplate;
...\ No newline at end of file ...\ No newline at end of file
1 'use strict';
2
3 function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }
4
5 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
7 function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
8
9 function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : _defaults(subClass, superClass); }
10
11 var Declaration = require('../declaration');
12
13 var ImageRendering = function (_Declaration) {
14 _inherits(ImageRendering, _Declaration);
15
16 function ImageRendering() {
17 _classCallCheck(this, ImageRendering);
18
19 return _possibleConstructorReturn(this, _Declaration.apply(this, arguments));
20 }
21
22 /**
23 * Add hack only for crisp-edges
24 */
25 ImageRendering.prototype.check = function check(decl) {
26 return decl.value === 'pixelated';
27 };
28
29 /**
30 * Change property name for IE
31 */
32
33
34 ImageRendering.prototype.prefixed = function prefixed(prop, prefix) {
35 if (prefix === '-ms-') {
36 return '-ms-interpolation-mode';
37 } else {
38 return _Declaration.prototype.prefixed.call(this, prop, prefix);
39 }
40 };
41
42 /**
43 * Change property and value for IE
44 */
45
46
47 ImageRendering.prototype.set = function set(decl, prefix) {
48 if (prefix !== '-ms-') return _Declaration.prototype.set.call(this, decl, prefix);
49 decl.prop = '-ms-interpolation-mode';
50 decl.value = 'nearest-neighbor';
51 return decl;
52 };
53
54 /**
55 * Return property name by spec
56 */
57
58
59 ImageRendering.prototype.normalize = function normalize() {
60 return 'image-rendering';
61 };
62
63 /**
64 * Warn on old value
65 */
66
67
68 ImageRendering.prototype.process = function process(node, result) {
69 return _Declaration.prototype.process.call(this, node, result);
70 };
71
72 return ImageRendering;
73 }(Declaration);
74
75 Object.defineProperty(ImageRendering, 'names', {
76 enumerable: true,
77 writable: true,
78 value: ['image-rendering', 'interpolation-mode']
79 });
80
81
82 module.exports = ImageRendering;
...\ No newline at end of file ...\ No newline at end of file
1 'use strict';
2
3 function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }
4
5 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
7 function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
8
9 function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : _defaults(subClass, superClass); }
10
11 var Value = require('../value');
12
13 var ImageSet = function (_Value) {
14 _inherits(ImageSet, _Value);
15
16 function ImageSet() {
17 _classCallCheck(this, ImageSet);
18
19 return _possibleConstructorReturn(this, _Value.apply(this, arguments));
20 }
21
22 /**
23 * Use non-standard name for WebKit and Firefox
24 */
25 ImageSet.prototype.replace = function replace(string, prefix) {
26 var fixed = _Value.prototype.replace.call(this, string, prefix);
27 if (prefix === '-webkit-') {
28 fixed = fixed.replace(/("[^"]+"|'[^']+')(\s+\d+\w)/gi, 'url($1)$2');
29 }
30 return fixed;
31 };
32
33 return ImageSet;
34 }(Value);
35
36 Object.defineProperty(ImageSet, 'names', {
37 enumerable: true,
38 writable: true,
39 value: ['image-set']
40 });
41
42
43 module.exports = ImageSet;
...\ No newline at end of file ...\ No newline at end of file
1 'use strict';
2
3 function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }
4
5 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
7 function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
8
9 function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : _defaults(subClass, superClass); }
10
11 var Declaration = require('../declaration');
12
13 var InlineLogical = function (_Declaration) {
14 _inherits(InlineLogical, _Declaration);
15
16 function InlineLogical() {
17 _classCallCheck(this, InlineLogical);
18
19 return _possibleConstructorReturn(this, _Declaration.apply(this, arguments));
20 }
21
22 /**
23 * Use old syntax for -moz- and -webkit-
24 */
25 InlineLogical.prototype.prefixed = function prefixed(prop, prefix) {
26 return prefix + prop.replace('-inline', '');
27 };
28
29 /**
30 * Return property name by spec
31 */
32
33
34 InlineLogical.prototype.normalize = function normalize(prop) {
35 return prop.replace(/(margin|padding|border)-(start|end)/, '$1-inline-$2');
36 };
37
38 return InlineLogical;
39 }(Declaration);
40
41 Object.defineProperty(InlineLogical, 'names', {
42 enumerable: true,
43 writable: true,
44 value: ['border-inline-start', 'border-inline-end', 'margin-inline-start', 'margin-inline-end', 'padding-inline-start', 'padding-inline-end', 'border-start', 'border-end', 'margin-start', 'margin-end', 'padding-start', 'padding-end']
45 });
46
47
48 module.exports = InlineLogical;
...\ No newline at end of file ...\ No newline at end of file
1 'use strict';
2
3 function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }
4
5 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
7 function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
8
9 function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : _defaults(subClass, superClass); }
10
11 var OldValue = require('../old-value');
12 var Value = require('../value');
13
14 function _regexp(name) {
15 return new RegExp('(^|[\\s,(])(' + name + '($|[\\s),]))', 'gi');
16 }
17
18 var Intrinsic = function (_Value) {
19 _inherits(Intrinsic, _Value);
20
21 function Intrinsic() {
22 _classCallCheck(this, Intrinsic);
23
24 return _possibleConstructorReturn(this, _Value.apply(this, arguments));
25 }
26
27 Intrinsic.prototype.regexp = function regexp() {
28 if (!this.regexpCache) this.regexpCache = _regexp(this.name);
29 return this.regexpCache;
30 };
31
32 Intrinsic.prototype.isStretch = function isStretch() {
33 return this.name === 'stretch' || this.name === 'fill' || this.name === 'fill-available';
34 };
35
36 Intrinsic.prototype.replace = function replace(string, prefix) {
37 if (prefix === '-moz-' && this.isStretch()) {
38 return string.replace(this.regexp(), '$1-moz-available$3');
39 } else if (prefix === '-webkit-' && this.isStretch()) {
40 return string.replace(this.regexp(), '$1-webkit-fill-available$3');
41 } else {
42 return _Value.prototype.replace.call(this, string, prefix);
43 }
44 };
45
46 Intrinsic.prototype.old = function old(prefix) {
47 var prefixed = prefix + this.name;
48 if (this.isStretch()) {
49 if (prefix === '-moz-') {
50 prefixed = '-moz-available';
51 } else if (prefix === '-webkit-') {
52 prefixed = '-webkit-fill-available';
53 }
54 }
55 return new OldValue(this.name, prefixed, prefixed, _regexp(prefixed));
56 };
57
58 Intrinsic.prototype.add = function add(decl, prefix) {
59 if (decl.prop.indexOf('grid') !== -1 && prefix !== '-webkit-') {
60 return undefined;
61 }
62 return _Value.prototype.add.call(this, decl, prefix);
63 };
64
65 return Intrinsic;
66 }(Value);
67
68 Object.defineProperty(Intrinsic, 'names', {
69 enumerable: true,
70 writable: true,
71 value: ['max-content', 'min-content', 'fit-content', 'fill', 'fill-available', 'stretch']
72 });
73
74
75 module.exports = Intrinsic;
...\ No newline at end of file ...\ No newline at end of file
1 'use strict';
2
3 function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }
4
5 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
7 function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
8
9 function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : _defaults(subClass, superClass); }
10
11 var flexSpec = require('./flex-spec');
12 var Declaration = require('../declaration');
13
14 var JustifyContent = function (_Declaration) {
15 _inherits(JustifyContent, _Declaration);
16
17 function JustifyContent() {
18 _classCallCheck(this, JustifyContent);
19
20 return _possibleConstructorReturn(this, _Declaration.apply(this, arguments));
21 }
22
23 /**
24 * Change property name for 2009 and 2012 specs
25 */
26 JustifyContent.prototype.prefixed = function prefixed(prop, prefix) {
27 var spec = void 0;
28
29 var _flexSpec = flexSpec(prefix);
30
31 spec = _flexSpec[0];
32 prefix = _flexSpec[1];
33
34 if (spec === 2009) {
35 return prefix + 'box-pack';
36 } else if (spec === 2012) {
37 return prefix + 'flex-pack';
38 } else {
39 return _Declaration.prototype.prefixed.call(this, prop, prefix);
40 }
41 };
42
43 /**
44 * Return property name by final spec
45 */
46
47
48 JustifyContent.prototype.normalize = function normalize() {
49 return 'justify-content';
50 };
51
52 /**
53 * Change value for 2009 and 2012 specs
54 */
55
56
57 JustifyContent.prototype.set = function set(decl, prefix) {
58 var spec = flexSpec(prefix)[0];
59 if (spec === 2009 || spec === 2012) {
60 var value = JustifyContent.oldValues[decl.value] || decl.value;
61 decl.value = value;
62 if (spec !== 2009 || value !== 'distribute') {
63 return _Declaration.prototype.set.call(this, decl, prefix);
64 }
65 } else if (spec === 'final') {
66 return _Declaration.prototype.set.call(this, decl, prefix);
67 }
68 return undefined;
69 };
70
71 return JustifyContent;
72 }(Declaration);
73
74 Object.defineProperty(JustifyContent, 'names', {
75 enumerable: true,
76 writable: true,
77 value: ['justify-content', 'flex-pack', 'box-pack']
78 });
79 Object.defineProperty(JustifyContent, 'oldValues', {
80 enumerable: true,
81 writable: true,
82 value: {
83 'flex-end': 'end',
84 'flex-start': 'start',
85 'space-between': 'justify',
86 'space-around': 'distribute'
87 }
88 });
89
90
91 module.exports = JustifyContent;
...\ No newline at end of file ...\ No newline at end of file
1 'use strict';
2
3 function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }
4
5 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
7 function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
8
9 function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : _defaults(subClass, superClass); }
10
11 var Declaration = require('../declaration');
12
13 var MaskBorder = function (_Declaration) {
14 _inherits(MaskBorder, _Declaration);
15
16 function MaskBorder() {
17 _classCallCheck(this, MaskBorder);
18
19 return _possibleConstructorReturn(this, _Declaration.apply(this, arguments));
20 }
21
22 /**
23 * Return property name by final spec
24 */
25 MaskBorder.prototype.normalize = function normalize() {
26 return this.name.replace('box-image', 'border');
27 };
28
29 /**
30 * Return flex property for 2012 spec
31 */
32
33
34 MaskBorder.prototype.prefixed = function prefixed(prop, prefix) {
35 var result = _Declaration.prototype.prefixed.call(this, prop, prefix);
36 if (prefix === '-webkit-') {
37 result = result.replace('border', 'box-image');
38 }
39 return result;
40 };
41
42 return MaskBorder;
43 }(Declaration);
44
45 Object.defineProperty(MaskBorder, 'names', {
46 enumerable: true,
47 writable: true,
48 value: ['mask-border', 'mask-border-source', 'mask-border-slice', 'mask-border-width', 'mask-border-outset', 'mask-border-repeat', 'mask-box-image', 'mask-box-image-source', 'mask-box-image-slice', 'mask-box-image-width', 'mask-box-image-outset', 'mask-box-image-repeat']
49 });
50
51
52 module.exports = MaskBorder;
...\ No newline at end of file ...\ No newline at end of file
1 'use strict';
2
3 function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }
4
5 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
7 function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
8
9 function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : _defaults(subClass, superClass); }
10
11 var flexSpec = require('./flex-spec');
12 var Declaration = require('../declaration');
13
14 var Order = function (_Declaration) {
15 _inherits(Order, _Declaration);
16
17 function Order() {
18 _classCallCheck(this, Order);
19
20 return _possibleConstructorReturn(this, _Declaration.apply(this, arguments));
21 }
22
23 /**
24 * Change property name for 2009 and 2012 specs
25 */
26 Order.prototype.prefixed = function prefixed(prop, prefix) {
27 var spec = void 0;
28
29 var _flexSpec = flexSpec(prefix);
30
31 spec = _flexSpec[0];
32 prefix = _flexSpec[1];
33
34 if (spec === 2009) {
35 return prefix + 'box-ordinal-group';
36 } else if (spec === 2012) {
37 return prefix + 'flex-order';
38 } else {
39 return _Declaration.prototype.prefixed.call(this, prop, prefix);
40 }
41 };
42
43 /**
44 * Return property name by final spec
45 */
46
47
48 Order.prototype.normalize = function normalize() {
49 return 'order';
50 };
51
52 /**
53 * Fix value for 2009 spec
54 */
55
56
57 Order.prototype.set = function set(decl, prefix) {
58 var spec = flexSpec(prefix)[0];
59 if (spec === 2009 && /\d/.test(decl.value)) {
60 decl.value = (parseInt(decl.value) + 1).toString();
61 return _Declaration.prototype.set.call(this, decl, prefix);
62 } else {
63 return _Declaration.prototype.set.call(this, decl, prefix);
64 }
65 };
66
67 return Order;
68 }(Declaration);
69
70 Object.defineProperty(Order, 'names', {
71 enumerable: true,
72 writable: true,
73 value: ['order', 'flex-order', 'box-ordinal-group']
74 });
75
76
77 module.exports = Order;
...\ No newline at end of file ...\ No newline at end of file
1 'use strict';
2
3 function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }
4
5 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
7 function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
8
9 function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : _defaults(subClass, superClass); }
10
11 var OldValue = require('../old-value');
12 var Value = require('../value');
13
14 var Pixelated = function (_Value) {
15 _inherits(Pixelated, _Value);
16
17 function Pixelated() {
18 _classCallCheck(this, Pixelated);
19
20 return _possibleConstructorReturn(this, _Value.apply(this, arguments));
21 }
22
23 /**
24 * Use non-standard name for WebKit and Firefox
25 */
26 Pixelated.prototype.replace = function replace(string, prefix) {
27 if (prefix === '-webkit-') {
28 return string.replace(this.regexp(), '$1-webkit-optimize-contrast');
29 } else if (prefix === '-moz-') {
30 return string.replace(this.regexp(), '$1-moz-crisp-edges');
31 } else {
32 return _Value.prototype.replace.call(this, string, prefix);
33 }
34 };
35
36 /**
37 * Different name for WebKit and Firefox
38 */
39
40
41 Pixelated.prototype.old = function old(prefix) {
42 if (prefix === '-webkit-') {
43 return new OldValue(this.name, '-webkit-optimize-contrast');
44 } else if (prefix === '-moz-') {
45 return new OldValue(this.name, '-moz-crisp-edges');
46 } else {
47 return _Value.prototype.old.call(this, prefix);
48 }
49 };
50
51 return Pixelated;
52 }(Value);
53
54 Object.defineProperty(Pixelated, 'names', {
55 enumerable: true,
56 writable: true,
57 value: ['pixelated']
58 });
59
60
61 module.exports = Pixelated;
...\ No newline at end of file ...\ No newline at end of file
1 'use strict';
2
3 function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }
4
5 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
7 function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
8
9 function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : _defaults(subClass, superClass); }
10
11 var Selector = require('../selector');
12
13 var Placeholder = function (_Selector) {
14 _inherits(Placeholder, _Selector);
15
16 function Placeholder() {
17 _classCallCheck(this, Placeholder);
18
19 return _possibleConstructorReturn(this, _Selector.apply(this, arguments));
20 }
21
22 /**
23 * Add old mozilla to possible prefixes
24 */
25 Placeholder.prototype.possible = function possible() {
26 return _Selector.prototype.possible.call(this).concat(['-moz- old', '-ms- old']);
27 };
28
29 /**
30 * Return different selectors depend on prefix
31 */
32
33
34 Placeholder.prototype.prefixed = function prefixed(prefix) {
35 if (prefix === '-webkit-') {
36 return '::-webkit-input-placeholder';
37 } else if (prefix === '-ms-') {
38 return '::-ms-input-placeholder';
39 } else if (prefix === '-ms- old') {
40 return ':-ms-input-placeholder';
41 } else if (prefix === '-moz- old') {
42 return ':-moz-placeholder';
43 } else {
44 return '::' + prefix + 'placeholder';
45 }
46 };
47
48 return Placeholder;
49 }(Selector);
50
51 Object.defineProperty(Placeholder, 'names', {
52 enumerable: true,
53 writable: true,
54 value: ['::placeholder']
55 });
56
57
58 module.exports = Placeholder;
...\ No newline at end of file ...\ No newline at end of file
1 'use strict';
2
3 function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }
4
5 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
7 function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
8
9 function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : _defaults(subClass, superClass); }
10
11 var Declaration = require('../declaration');
12
13 var BASIC = ['none', 'underline', 'overline', 'line-through', 'blink', 'inherit', 'initial', 'unset'];
14
15 var TextDecoration = function (_Declaration) {
16 _inherits(TextDecoration, _Declaration);
17
18 function TextDecoration() {
19 _classCallCheck(this, TextDecoration);
20
21 return _possibleConstructorReturn(this, _Declaration.apply(this, arguments));
22 }
23
24 /**
25 * Do not add prefixes for basic values.
26 */
27 TextDecoration.prototype.check = function check(decl) {
28 return decl.value.split(/\s+/).some(function (i) {
29 return BASIC.indexOf(i) === -1;
30 });
31 };
32
33 return TextDecoration;
34 }(Declaration);
35
36 Object.defineProperty(TextDecoration, 'names', {
37 enumerable: true,
38 writable: true,
39 value: ['text-decoration']
40 });
41
42
43 module.exports = TextDecoration;
...\ No newline at end of file ...\ No newline at end of file
1 'use strict';
2
3 function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }
4
5 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
7 function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
8
9 function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : _defaults(subClass, superClass); }
10
11 var Declaration = require('../declaration');
12
13 var TextEmphasisPosition = function (_Declaration) {
14 _inherits(TextEmphasisPosition, _Declaration);
15
16 function TextEmphasisPosition() {
17 _classCallCheck(this, TextEmphasisPosition);
18
19 return _possibleConstructorReturn(this, _Declaration.apply(this, arguments));
20 }
21
22 TextEmphasisPosition.prototype.set = function set(decl, prefix) {
23 if (prefix === '-webkit-') {
24 decl.value = decl.value.replace(/\s*(right|left)\s*/i, '');
25 }
26 return _Declaration.prototype.set.call(this, decl, prefix);
27 };
28
29 return TextEmphasisPosition;
30 }(Declaration);
31
32 Object.defineProperty(TextEmphasisPosition, 'names', {
33 enumerable: true,
34 writable: true,
35 value: ['text-emphasis-position']
36 });
37
38
39 module.exports = TextEmphasisPosition;
...\ No newline at end of file ...\ No newline at end of file
1 'use strict';
2
3 function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }
4
5 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
7 function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
8
9 function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : _defaults(subClass, superClass); }
10
11 var Declaration = require('../declaration');
12
13 var TransformDecl = function (_Declaration) {
14 _inherits(TransformDecl, _Declaration);
15
16 function TransformDecl() {
17 _classCallCheck(this, TransformDecl);
18
19 return _possibleConstructorReturn(this, _Declaration.apply(this, arguments));
20 }
21
22 /**
23 * Recursively check all parents for @keyframes
24 */
25 TransformDecl.prototype.keyframeParents = function keyframeParents(decl) {
26 var parent = decl.parent;
27
28 while (parent) {
29 if (parent.type === 'atrule' && parent.name === 'keyframes') {
30 return true;
31 }
32 var _parent = parent;
33 parent = _parent.parent;
34 }
35 return false;
36 };
37
38 /**
39 * Is transform contain 3D commands
40 */
41
42
43 TransformDecl.prototype.contain3d = function contain3d(decl) {
44 if (decl.prop === 'transform-origin') {
45 return false;
46 }
47
48 for (var _iterator = TransformDecl.functions3d, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
49 var _ref;
50
51 if (_isArray) {
52 if (_i >= _iterator.length) break;
53 _ref = _iterator[_i++];
54 } else {
55 _i = _iterator.next();
56 if (_i.done) break;
57 _ref = _i.value;
58 }
59
60 var func = _ref;
61
62 if (decl.value.indexOf(func + '(') !== -1) {
63 return true;
64 }
65 }
66
67 return false;
68 };
69
70 /**
71 * Replace rotateZ to rotate for IE 9
72 */
73
74
75 TransformDecl.prototype.set = function set(decl, prefix) {
76 decl = _Declaration.prototype.set.call(this, decl, prefix);
77 if (prefix === '-ms-') {
78 decl.value = decl.value.replace(/rotateZ/gi, 'rotate');
79 }
80 return decl;
81 };
82
83 /**
84 * Don't add prefix for IE in keyframes
85 */
86
87
88 TransformDecl.prototype.insert = function insert(decl, prefix, prefixes) {
89 if (prefix === '-ms-') {
90 if (!this.contain3d(decl) && !this.keyframeParents(decl)) {
91 return _Declaration.prototype.insert.call(this, decl, prefix, prefixes);
92 }
93 } else if (prefix === '-o-') {
94 if (!this.contain3d(decl)) {
95 return _Declaration.prototype.insert.call(this, decl, prefix, prefixes);
96 }
97 } else {
98 return _Declaration.prototype.insert.call(this, decl, prefix, prefixes);
99 }
100 return undefined;
101 };
102
103 return TransformDecl;
104 }(Declaration);
105
106 Object.defineProperty(TransformDecl, 'names', {
107 enumerable: true,
108 writable: true,
109 value: ['transform', 'transform-origin']
110 });
111 Object.defineProperty(TransformDecl, 'functions3d', {
112 enumerable: true,
113 writable: true,
114 value: ['matrix3d', 'translate3d', 'translateZ', 'scale3d', 'scaleZ', 'rotate3d', 'rotateX', 'rotateY', 'perspective']
115 });
116
117
118 module.exports = TransformDecl;
...\ No newline at end of file ...\ No newline at end of file
1 'use strict';
2
3 function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }
4
5 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
7 function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
8
9 function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : _defaults(subClass, superClass); }
10
11 var Declaration = require('../declaration');
12
13 var WritingMode = function (_Declaration) {
14 _inherits(WritingMode, _Declaration);
15
16 function WritingMode() {
17 _classCallCheck(this, WritingMode);
18
19 return _possibleConstructorReturn(this, _Declaration.apply(this, arguments));
20 }
21
22 WritingMode.prototype.set = function set(decl, prefix) {
23 if (prefix === '-ms-') {
24 decl.value = WritingMode.msValues[decl.value] || decl.value;
25 return _Declaration.prototype.set.call(this, decl, prefix);
26 } else {
27 return _Declaration.prototype.set.call(this, decl, prefix);
28 }
29 };
30
31 return WritingMode;
32 }(Declaration);
33
34 Object.defineProperty(WritingMode, 'names', {
35 enumerable: true,
36 writable: true,
37 value: ['writing-mode']
38 });
39 Object.defineProperty(WritingMode, 'msValues', {
40 enumerable: true,
41 writable: true,
42 value: {
43 'horizontal-tb': 'lr-tb',
44 'vertical-rl': 'tb-rl',
45 'vertical-lr': 'tb-lr'
46 }
47 });
48
49
50 module.exports = WritingMode;
...\ No newline at end of file ...\ No newline at end of file
1 'use strict';
2
3 var browserslist = require('browserslist');
4
5 function capitalize(str) {
6 return str.slice(0, 1).toUpperCase() + str.slice(1);
7 }
8
9 var names = {
10 ie: 'IE',
11 ie_mob: 'IE Mobile',
12 ios_saf: 'iOS',
13 op_mini: 'Opera Mini',
14 op_mob: 'Opera Mobile',
15 and_chr: 'Chrome for Android',
16 and_ff: 'Firefox for Android',
17 and_uc: 'UC for Android'
18 };
19
20 var prefix = function prefix(name, prefixes) {
21 var out = ' ' + name + ': ';
22 out += prefixes.map(function (i) {
23 return i.replace(/^-(.*)-$/g, '$1');
24 }).join(', ');
25 out += '\n';
26 return out;
27 };
28
29 module.exports = function (prefixes) {
30 if (prefixes.browsers.selected.length === 0) {
31 return 'No browsers selected';
32 }
33
34 var versions = {};
35 for (var _iterator = prefixes.browsers.selected, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
36 var _ref;
37
38 if (_isArray) {
39 if (_i >= _iterator.length) break;
40 _ref = _iterator[_i++];
41 } else {
42 _i = _iterator.next();
43 if (_i.done) break;
44 _ref = _i.value;
45 }
46
47 var browser = _ref;
48
49 var _browser$split = browser.split(' '),
50 name = _browser$split[0],
51 version = _browser$split[1];
52
53 name = names[name] || capitalize(name);
54 if (versions[name]) {
55 versions[name].push(version);
56 } else {
57 versions[name] = [version];
58 }
59 }
60
61 var out = 'Browsers:\n';
62 for (var _browser in versions) {
63 var list = versions[_browser];
64 list = list.sort(function (a, b) {
65 return parseFloat(b) - parseFloat(a);
66 });
67 out += ' ' + _browser + ': ' + list.join(', ') + '\n';
68 }
69
70 var coverage = browserslist.coverage(prefixes.browsers.selected);
71 var round = Math.round(coverage * 100) / 100.0;
72 out += '\nThese browsers account for ' + round + '% of all users globally\n';
73
74 var atrules = '';
75 for (var name in prefixes.add) {
76 var data = prefixes.add[name];
77 if (name[0] === '@' && data.prefixes) {
78 atrules += prefix(name, data.prefixes);
79 }
80 }
81 if (atrules !== '') {
82 out += '\nAt-Rules:\n' + atrules;
83 }
84
85 var selectors = '';
86 for (var _iterator2 = prefixes.add.selectors, _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : _iterator2[Symbol.iterator]();;) {
87 var _ref2;
88
89 if (_isArray2) {
90 if (_i2 >= _iterator2.length) break;
91 _ref2 = _iterator2[_i2++];
92 } else {
93 _i2 = _iterator2.next();
94 if (_i2.done) break;
95 _ref2 = _i2.value;
96 }
97
98 var selector = _ref2;
99
100 if (selector.prefixes) {
101 selectors += prefix(selector.name, selector.prefixes);
102 }
103 }
104 if (selectors !== '') {
105 out += '\nSelectors:\n' + selectors;
106 }
107
108 var values = '';
109 var props = '';
110 for (var _name in prefixes.add) {
111 var _data = prefixes.add[_name];
112 if (_name[0] !== '@' && _data.prefixes) {
113 props += prefix(_name, _data.prefixes);
114 }
115
116 if (!_data.values) {
117 continue;
118 }
119 for (var _iterator3 = _data.values, _isArray3 = Array.isArray(_iterator3), _i3 = 0, _iterator3 = _isArray3 ? _iterator3 : _iterator3[Symbol.iterator]();;) {
120 var _ref3;
121
122 if (_isArray3) {
123 if (_i3 >= _iterator3.length) break;
124 _ref3 = _iterator3[_i3++];
125 } else {
126 _i3 = _iterator3.next();
127 if (_i3.done) break;
128 _ref3 = _i3.value;
129 }
130
131 var value = _ref3;
132
133 var string = prefix(value.name, value.prefixes);
134 if (values.indexOf(string) === -1) {
135 values += string;
136 }
137 }
138 }
139
140 if (props !== '') {
141 out += '\nProperties:\n' + props;
142 }
143 if (values !== '') {
144 out += '\nValues:\n' + values;
145 }
146
147 if (atrules === '' && selectors === '' && props === '' && values === '') {
148 out += '\nAwesome! Your browsers don\'t require any vendor prefixes.' + '\nNow you can remove Autoprefixer from build steps.';
149 }
150
151 return out;
152 };
...\ No newline at end of file ...\ No newline at end of file
1 "use strict";
2
3 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
4
5 var OldSelector = function () {
6 function OldSelector(selector, prefix) {
7 _classCallCheck(this, OldSelector);
8
9 this.prefix = prefix;
10 this.prefixed = selector.prefixed(this.prefix);
11 this.regexp = selector.regexp(this.prefix);
12
13 this.prefixeds = selector.possible().map(function (x) {
14 return [selector.prefixed(x), selector.regexp(x)];
15 });
16
17 this.unprefixed = selector.name;
18 this.nameRegexp = selector.regexp();
19 }
20
21 /**
22 * Is rule a hack without unprefixed version bottom
23 */
24
25
26 OldSelector.prototype.isHack = function isHack(rule) {
27 var index = rule.parent.index(rule) + 1;
28 var rules = rule.parent.nodes;
29
30 while (index < rules.length) {
31 var before = rules[index].selector;
32 if (!before) {
33 return true;
34 }
35
36 if (before.indexOf(this.unprefixed) !== -1 && before.match(this.nameRegexp)) {
37 return false;
38 }
39
40 var some = false;
41 for (var _iterator = this.prefixeds, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
42 var _ref2;
43
44 if (_isArray) {
45 if (_i >= _iterator.length) break;
46 _ref2 = _iterator[_i++];
47 } else {
48 _i = _iterator.next();
49 if (_i.done) break;
50 _ref2 = _i.value;
51 }
52
53 var _ref = _ref2;
54 var string = _ref[0];
55 var regexp = _ref[1];
56
57 if (before.indexOf(string) !== -1 && before.match(regexp)) {
58 some = true;
59 break;
60 }
61 }
62
63 if (!some) {
64 return true;
65 }
66
67 index += 1;
68 }
69
70 return true;
71 };
72
73 /**
74 * Does rule contain an unnecessary prefixed selector
75 */
76
77
78 OldSelector.prototype.check = function check(rule) {
79 if (rule.selector.indexOf(this.prefixed) === -1) {
80 return false;
81 }
82 if (!rule.selector.match(this.regexp)) {
83 return false;
84 }
85 if (this.isHack(rule)) {
86 return false;
87 }
88 return true;
89 };
90
91 return OldSelector;
92 }();
93
94 module.exports = OldSelector;
...\ No newline at end of file ...\ No newline at end of file
1 'use strict';
2
3 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
4
5 var utils = require('./utils');
6
7 var OldValue = function () {
8 function OldValue(unprefixed, prefixed, string, regexp) {
9 _classCallCheck(this, OldValue);
10
11 this.unprefixed = unprefixed;
12 this.prefixed = prefixed;
13 this.string = string || prefixed;
14 this.regexp = regexp || utils.regexp(prefixed);
15 }
16
17 /**
18 * Check, that value contain old value
19 */
20
21
22 OldValue.prototype.check = function check(value) {
23 if (value.indexOf(this.string) !== -1) {
24 return !!value.match(this.regexp);
25 }
26 return false;
27 };
28
29 return OldValue;
30 }();
31
32 module.exports = OldValue;
...\ No newline at end of file ...\ No newline at end of file
1 'use strict';
2
3 var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
4
5 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
7 var Browsers = require('./browsers');
8 var utils = require('./utils');
9
10 var vendor = require('postcss').vendor;
11
12 /**
13 * Recursivly clone objects
14 */
15 function _clone(obj, parent) {
16 var cloned = new obj.constructor();
17
18 for (var _iterator = Object.keys(obj || {}), _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
19 var _ref;
20
21 if (_isArray) {
22 if (_i >= _iterator.length) break;
23 _ref = _iterator[_i++];
24 } else {
25 _i = _iterator.next();
26 if (_i.done) break;
27 _ref = _i.value;
28 }
29
30 var i = _ref;
31
32 var value = obj[i];
33 if (i === 'parent' && (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object') {
34 if (parent) {
35 cloned[i] = parent;
36 }
37 } else if (i === 'source' || i === null) {
38 cloned[i] = value;
39 } else if (value instanceof Array) {
40 cloned[i] = value.map(function (x) {
41 return _clone(x, cloned);
42 });
43 } else if (i !== '_autoprefixerPrefix' && i !== '_autoprefixerValues') {
44 if ((typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object' && value !== null) {
45 value = _clone(value, cloned);
46 }
47 cloned[i] = value;
48 }
49 }
50
51 return cloned;
52 }
53
54 var Prefixer = function () {
55
56 /**
57 * Add hack to selected names
58 */
59 Prefixer.hack = function hack(klass) {
60 var _this = this;
61
62 if (!this.hacks) {
63 this.hacks = {};
64 }
65 return klass.names.map(function (name) {
66 _this.hacks[name] = klass;
67 return _this.hacks[name];
68 });
69 };
70
71 /**
72 * Load hacks for some names
73 */
74
75
76 Prefixer.load = function load(name, prefixes, all) {
77 var Klass = this.hacks && this.hacks[name];
78 if (Klass) {
79 return new Klass(name, prefixes, all);
80 } else {
81 return new this(name, prefixes, all);
82 }
83 };
84
85 /**
86 * Clone node and clean autprefixer custom caches
87 */
88
89
90 Prefixer.clone = function clone(node, overrides) {
91 var cloned = _clone(node);
92 for (var name in overrides) {
93 cloned[name] = overrides[name];
94 }
95 return cloned;
96 };
97
98 function Prefixer(name, prefixes, all) {
99 _classCallCheck(this, Prefixer);
100
101 this.name = name;
102 this.prefixes = prefixes;
103 this.all = all;
104 }
105
106 /**
107 * Find prefix in node parents
108 */
109
110
111 Prefixer.prototype.parentPrefix = function parentPrefix(node) {
112 var prefix = void 0;
113
114 if (typeof node._autoprefixerPrefix !== 'undefined') {
115 prefix = node._autoprefixerPrefix;
116 } else if (node.type === 'decl' && node.prop[0] === '-') {
117 prefix = vendor.prefix(node.prop);
118 } else if (node.type === 'root') {
119 prefix = false;
120 } else if (node.type === 'rule' && node.selector.indexOf(':-') !== -1 && /:(-\w+-)/.test(node.selector)) {
121 prefix = node.selector.match(/:(-\w+-)/)[1];
122 } else if (node.type === 'atrule' && node.name[0] === '-') {
123 prefix = vendor.prefix(node.name);
124 } else {
125 prefix = this.parentPrefix(node.parent);
126 }
127
128 if (Browsers.prefixes().indexOf(prefix) === -1) {
129 prefix = false;
130 }
131
132 node._autoprefixerPrefix = prefix;
133
134 return node._autoprefixerPrefix;
135 };
136
137 /**
138 * Clone node with prefixes
139 */
140
141
142 Prefixer.prototype.process = function process(node, result) {
143 if (!this.check(node)) {
144 return undefined;
145 }
146
147 var parent = this.parentPrefix(node);
148
149 var prefixes = this.prefixes.filter(function (prefix) {
150 return !parent || parent === utils.removeNote(prefix);
151 });
152
153 var added = [];
154 for (var _iterator2 = prefixes, _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : _iterator2[Symbol.iterator]();;) {
155 var _ref2;
156
157 if (_isArray2) {
158 if (_i2 >= _iterator2.length) break;
159 _ref2 = _iterator2[_i2++];
160 } else {
161 _i2 = _iterator2.next();
162 if (_i2.done) break;
163 _ref2 = _i2.value;
164 }
165
166 var prefix = _ref2;
167
168 if (this.add(node, prefix, added.concat([prefix]), result)) {
169 added.push(prefix);
170 }
171 }
172
173 return added;
174 };
175
176 /**
177 * Shortcut for Prefixer.clone
178 */
179
180
181 Prefixer.prototype.clone = function clone(node, overrides) {
182 return Prefixer.clone(node, overrides);
183 };
184
185 return Prefixer;
186 }();
187
188 module.exports = Prefixer;
...\ No newline at end of file ...\ No newline at end of file
1 'use strict';
2
3 function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }
4
5 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
7 function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
8
9 function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : _defaults(subClass, superClass); }
10
11 var Prefixer = require('./prefixer');
12 var utils = require('./utils');
13
14 var n2f = require('num2fraction');
15
16 var regexp = /(min|max)-resolution\s*:\s*\d*\.?\d+(dppx|dpi)/gi;
17 var split = /(min|max)-resolution(\s*:\s*)(\d*\.?\d+)(dppx|dpi)/i;
18
19 var Resolution = function (_Prefixer) {
20 _inherits(Resolution, _Prefixer);
21
22 function Resolution() {
23 _classCallCheck(this, Resolution);
24
25 return _possibleConstructorReturn(this, _Prefixer.apply(this, arguments));
26 }
27
28 /**
29 * Return prefixed query name
30 */
31 Resolution.prototype.prefixName = function prefixName(prefix, name) {
32 var newName = prefix === '-moz-' ? name + '--moz-device-pixel-ratio' : prefix + name + '-device-pixel-ratio';
33 return newName;
34 };
35
36 /**
37 * Return prefixed query
38 */
39
40
41 Resolution.prototype.prefixQuery = function prefixQuery(prefix, name, colon, value, units) {
42 if (units === 'dpi') {
43 value = Number(value / 96);
44 }
45 if (prefix === '-o-') {
46 value = n2f(value);
47 }
48 return this.prefixName(prefix, name) + colon + value;
49 };
50
51 /**
52 * Remove prefixed queries
53 */
54
55
56 Resolution.prototype.clean = function clean(rule) {
57 var _this2 = this;
58
59 if (!this.bad) {
60 this.bad = [];
61 for (var _iterator = this.prefixes, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
62 var _ref;
63
64 if (_isArray) {
65 if (_i >= _iterator.length) break;
66 _ref = _iterator[_i++];
67 } else {
68 _i = _iterator.next();
69 if (_i.done) break;
70 _ref = _i.value;
71 }
72
73 var prefix = _ref;
74
75 this.bad.push(this.prefixName(prefix, 'min'));
76 this.bad.push(this.prefixName(prefix, 'max'));
77 }
78 }
79
80 rule.params = utils.editList(rule.params, function (queries) {
81 return queries.filter(function (query) {
82 return _this2.bad.every(function (i) {
83 return query.indexOf(i) === -1;
84 });
85 });
86 });
87 };
88
89 /**
90 * Add prefixed queries
91 */
92
93
94 Resolution.prototype.process = function process(rule) {
95 var _this3 = this;
96
97 var parent = this.parentPrefix(rule);
98 var prefixes = parent ? [parent] : this.prefixes;
99
100 rule.params = utils.editList(rule.params, function (origin, prefixed) {
101 for (var _iterator2 = origin, _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : _iterator2[Symbol.iterator]();;) {
102 var _ref2;
103
104 if (_isArray2) {
105 if (_i2 >= _iterator2.length) break;
106 _ref2 = _iterator2[_i2++];
107 } else {
108 _i2 = _iterator2.next();
109 if (_i2.done) break;
110 _ref2 = _i2.value;
111 }
112
113 var query = _ref2;
114
115 if (query.indexOf('min-resolution') === -1 && query.indexOf('max-resolution') === -1) {
116 prefixed.push(query);
117 continue;
118 }
119
120 var _loop = function _loop(prefix) {
121 var processed = query.replace(regexp, function (str) {
122 var parts = str.match(split);
123 return _this3.prefixQuery(prefix, parts[1], parts[2], parts[3], parts[4]);
124 });
125 prefixed.push(processed);
126 };
127
128 for (var _iterator3 = prefixes, _isArray3 = Array.isArray(_iterator3), _i3 = 0, _iterator3 = _isArray3 ? _iterator3 : _iterator3[Symbol.iterator]();;) {
129 var _ref3;
130
131 if (_isArray3) {
132 if (_i3 >= _iterator3.length) break;
133 _ref3 = _iterator3[_i3++];
134 } else {
135 _i3 = _iterator3.next();
136 if (_i3.done) break;
137 _ref3 = _i3.value;
138 }
139
140 var prefix = _ref3;
141
142 _loop(prefix);
143 }
144 prefixed.push(query);
145 }
146
147 return utils.uniq(prefixed);
148 });
149 };
150
151 return Resolution;
152 }(Prefixer);
153
154 module.exports = Resolution;
...\ No newline at end of file ...\ No newline at end of file
1 'use strict';
2
3 function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }
4
5 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
7 function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
8
9 function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : _defaults(subClass, superClass); }
10
11 var OldSelector = require('./old-selector');
12 var Prefixer = require('./prefixer');
13 var Browsers = require('./browsers');
14 var utils = require('./utils');
15
16 var Selector = function (_Prefixer) {
17 _inherits(Selector, _Prefixer);
18
19 function Selector(name, prefixes, all) {
20 _classCallCheck(this, Selector);
21
22 var _this = _possibleConstructorReturn(this, _Prefixer.call(this, name, prefixes, all));
23
24 _this.regexpCache = {};
25 return _this;
26 }
27
28 /**
29 * Is rule selectors need to be prefixed
30 */
31
32
33 Selector.prototype.check = function check(rule) {
34 if (rule.selector.indexOf(this.name) !== -1) {
35 return !!rule.selector.match(this.regexp());
36 }
37
38 return false;
39 };
40
41 /**
42 * Return prefixed version of selector
43 */
44
45
46 Selector.prototype.prefixed = function prefixed(prefix) {
47 return this.name.replace(/^([^\w]*)/, '$1' + prefix);
48 };
49
50 /**
51 * Lazy loadRegExp for name
52 */
53
54
55 Selector.prototype.regexp = function regexp(prefix) {
56 if (this.regexpCache[prefix]) {
57 return this.regexpCache[prefix];
58 }
59
60 var name = prefix ? this.prefixed(prefix) : this.name;
61 this.regexpCache[prefix] = new RegExp('(^|[^:"\'=])' + utils.escapeRegexp(name), 'gi');
62 return this.regexpCache[prefix];
63 };
64
65 /**
66 * All possible prefixes
67 */
68
69
70 Selector.prototype.possible = function possible() {
71 return Browsers.prefixes();
72 };
73
74 /**
75 * Return all possible selector prefixes
76 */
77
78
79 Selector.prototype.prefixeds = function prefixeds(rule) {
80 if (rule._autoprefixerPrefixeds) {
81 return rule._autoprefixerPrefixeds;
82 }
83
84 var prefixeds = {};
85 for (var _iterator = this.possible(), _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
86 var _ref;
87
88 if (_isArray) {
89 if (_i >= _iterator.length) break;
90 _ref = _iterator[_i++];
91 } else {
92 _i = _iterator.next();
93 if (_i.done) break;
94 _ref = _i.value;
95 }
96
97 var prefix = _ref;
98
99 prefixeds[prefix] = this.replace(rule.selector, prefix);
100 }
101
102 rule._autoprefixerPrefixeds = prefixeds;
103 return rule._autoprefixerPrefixeds;
104 };
105
106 /**
107 * Is rule already prefixed before
108 */
109
110
111 Selector.prototype.already = function already(rule, prefixeds, prefix) {
112 var index = rule.parent.index(rule) - 1;
113
114 while (index >= 0) {
115 var before = rule.parent.nodes[index];
116
117 if (before.type !== 'rule') {
118 return false;
119 }
120
121 var some = false;
122 for (var key in prefixeds) {
123 var prefixed = prefixeds[key];
124 if (before.selector === prefixed) {
125 if (prefix === key) {
126 return true;
127 } else {
128 some = true;
129 break;
130 }
131 }
132 }
133 if (!some) {
134 return false;
135 }
136
137 index -= 1;
138 }
139
140 return false;
141 };
142
143 /**
144 * Replace selectors by prefixed one
145 */
146
147
148 Selector.prototype.replace = function replace(selector, prefix) {
149 return selector.replace(this.regexp(), '$1' + this.prefixed(prefix));
150 };
151
152 /**
153 * Clone and add prefixes for at-rule
154 */
155
156
157 Selector.prototype.add = function add(rule, prefix) {
158 var prefixeds = this.prefixeds(rule);
159
160 if (this.already(rule, prefixeds, prefix)) {
161 return;
162 }
163
164 var cloned = this.clone(rule, { selector: prefixeds[prefix] });
165 rule.parent.insertBefore(rule, cloned);
166 };
167
168 /**
169 * Return function to fast find prefixed selector
170 */
171
172
173 Selector.prototype.old = function old(prefix) {
174 return new OldSelector(this, prefix);
175 };
176
177 return Selector;
178 }(Prefixer);
179
180 module.exports = Selector;
...\ No newline at end of file ...\ No newline at end of file
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.