placeholder.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. 'use strict';
  2. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3. 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; }
  4. 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) : subClass.__proto__ = superClass; }
  5. var Selector = require('../selector');
  6. var Placeholder = function (_Selector) {
  7. _inherits(Placeholder, _Selector);
  8. function Placeholder() {
  9. _classCallCheck(this, Placeholder);
  10. return _possibleConstructorReturn(this, _Selector.apply(this, arguments));
  11. }
  12. /**
  13. * Add old mozilla to possible prefixes
  14. */
  15. Placeholder.prototype.possible = function possible() {
  16. return _Selector.prototype.possible.call(this).concat(['-moz- old', '-ms- old']);
  17. };
  18. /**
  19. * Return different selectors depend on prefix
  20. */
  21. Placeholder.prototype.prefixed = function prefixed(prefix) {
  22. if (prefix === '-webkit-') {
  23. return '::-webkit-input-placeholder';
  24. } else if (prefix === '-ms-') {
  25. return '::-ms-input-placeholder';
  26. } else if (prefix === '-ms- old') {
  27. return ':-ms-input-placeholder';
  28. } else if (prefix === '-moz- old') {
  29. return ':-moz-placeholder';
  30. } else {
  31. return '::' + prefix + 'placeholder';
  32. }
  33. };
  34. return Placeholder;
  35. }(Selector);
  36. Object.defineProperty(Placeholder, 'names', {
  37. enumerable: true,
  38. writable: true,
  39. value: ['::placeholder']
  40. });
  41. module.exports = Placeholder;