MatcherList.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. //.CommonJS
  2. var CSSOM = {};
  3. ///CommonJS
  4. /**
  5. * @constructor
  6. * @see https://developer.mozilla.org/en/CSS/@-moz-document
  7. */
  8. CSSOM.MatcherList = function MatcherList(){
  9. this.length = 0;
  10. };
  11. CSSOM.MatcherList.prototype = {
  12. constructor: CSSOM.MatcherList,
  13. /**
  14. * @return {string}
  15. */
  16. get matcherText() {
  17. return Array.prototype.join.call(this, ", ");
  18. },
  19. /**
  20. * @param {string} value
  21. */
  22. set matcherText(value) {
  23. // just a temporary solution, actually it may be wrong by just split the value with ',', because a url can include ','.
  24. var values = value.split(",");
  25. var length = this.length = values.length;
  26. for (var i=0; i<length; i++) {
  27. this[i] = values[i].trim();
  28. }
  29. },
  30. /**
  31. * @param {string} matcher
  32. */
  33. appendMatcher: function(matcher) {
  34. if (Array.prototype.indexOf.call(this, matcher) === -1) {
  35. this[this.length] = matcher;
  36. this.length++;
  37. }
  38. },
  39. /**
  40. * @param {string} matcher
  41. */
  42. deleteMatcher: function(matcher) {
  43. var index = Array.prototype.indexOf.call(this, matcher);
  44. if (index !== -1) {
  45. Array.prototype.splice.call(this, index, 1);
  46. }
  47. }
  48. };
  49. //.CommonJS
  50. exports.MatcherList = CSSOM.MatcherList;
  51. ///CommonJS