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