htmlFirstChild.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. 'use strict';
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. var _postcssSelectorParser = require('postcss-selector-parser');
  6. var _postcssSelectorParser2 = _interopRequireDefault(_postcssSelectorParser);
  7. var _exists = require('../exists');
  8. var _exists2 = _interopRequireDefault(_exists);
  9. var _isMixin = require('../isMixin');
  10. var _isMixin2 = _interopRequireDefault(_isMixin);
  11. var _plugin = require('../plugin');
  12. var _plugin2 = _interopRequireDefault(_plugin);
  13. var _browsers = require('../dictionary/browsers');
  14. var _identifiers = require('../dictionary/identifiers');
  15. var _postcss = require('../dictionary/postcss');
  16. var _tags = require('../dictionary/tags');
  17. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  18. function analyse(ctx, rule) {
  19. return selectors => {
  20. selectors.each(selector => {
  21. if ((0, _exists2.default)(selector, 0, _tags.HTML) && (0, _exists2.default)(selector, 1, ':first-child') && (0, _exists2.default)(selector, 2, ' ') && selector.at(3)) {
  22. ctx.push(rule, {
  23. identifier: _identifiers.SELECTOR,
  24. hack: selector.toString()
  25. });
  26. }
  27. });
  28. };
  29. }
  30. exports.default = (0, _plugin2.default)([_browsers.OP_9], [_postcss.RULE], function (rule) {
  31. if ((0, _isMixin2.default)(rule)) {
  32. return;
  33. }
  34. (0, _postcssSelectorParser2.default)(analyse(this, rule)).processSync(rule.selector);
  35. });
  36. module.exports = exports['default'];