leadingStar.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. 'use strict';
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. var _plugin = require('../plugin');
  6. var _plugin2 = _interopRequireDefault(_plugin);
  7. var _browsers = require('../dictionary/browsers');
  8. var _identifiers = require('../dictionary/identifiers');
  9. var _postcss = require('../dictionary/postcss');
  10. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  11. const hacks = '!_$_&_*_)_=_%_+_,_._/_`_]_#_~_?_:_|'.split('_');
  12. exports.default = (0, _plugin2.default)([_browsers.IE_5_5, _browsers.IE_6, _browsers.IE_7], [_postcss.ATRULE, _postcss.DECL], function (node) {
  13. if (node.type === _postcss.DECL) {
  14. // some values are not picked up by before, so ensure they are
  15. // at the beginning of the value
  16. hacks.some(hack => {
  17. if (!node.prop.indexOf(hack)) {
  18. this.push(node, {
  19. identifier: _identifiers.PROPERTY,
  20. hack: node.prop
  21. });
  22. return true;
  23. }
  24. });
  25. let { before } = node.raws;
  26. if (!before) {
  27. return;
  28. }
  29. hacks.some(hack => {
  30. if (~before.indexOf(hack)) {
  31. this.push(node, {
  32. identifier: _identifiers.PROPERTY,
  33. hack: `${before.trim()}${node.prop}`
  34. });
  35. return true;
  36. }
  37. });
  38. } else {
  39. // test for the @property: value; hack
  40. let { name } = node;
  41. let len = name.length - 1;
  42. if (name.lastIndexOf(':') === len) {
  43. this.push(node, {
  44. identifier: _identifiers.PROPERTY,
  45. hack: `@${name.substr(0, len)}`
  46. });
  47. }
  48. }
  49. });
  50. module.exports = exports['default'];