Edit File by line
/home/barbar84/www/wp-inclu.../js/codemirr...
File: csslint.js
[4000] Fix | Delete
},{}],11:[function(require,module,exports){
[4001] Fix | Delete
"use strict";
[4002] Fix | Delete
[4003] Fix | Delete
module.exports = PropertyValuePart;
[4004] Fix | Delete
[4005] Fix | Delete
var SyntaxUnit = require("../util/SyntaxUnit");
[4006] Fix | Delete
[4007] Fix | Delete
var Colors = require("./Colors");
[4008] Fix | Delete
var Parser = require("./Parser");
[4009] Fix | Delete
var Tokens = require("./Tokens");
[4010] Fix | Delete
[4011] Fix | Delete
/**
[4012] Fix | Delete
* Represents a single part of a CSS property value, meaning that it represents
[4013] Fix | Delete
* just one part of the data between ":" and ";".
[4014] Fix | Delete
* @param {String} text The text representation of the unit.
[4015] Fix | Delete
* @param {int} line The line of text on which the unit resides.
[4016] Fix | Delete
* @param {int} col The column of text on which the unit resides.
[4017] Fix | Delete
* @namespace parserlib.css
[4018] Fix | Delete
* @class PropertyValuePart
[4019] Fix | Delete
* @extends parserlib.util.SyntaxUnit
[4020] Fix | Delete
* @constructor
[4021] Fix | Delete
*/
[4022] Fix | Delete
function PropertyValuePart(text, line, col, optionalHint) {
[4023] Fix | Delete
var hint = optionalHint || {};
[4024] Fix | Delete
[4025] Fix | Delete
SyntaxUnit.call(this, text, line, col, Parser.PROPERTY_VALUE_PART_TYPE);
[4026] Fix | Delete
[4027] Fix | Delete
/**
[4028] Fix | Delete
* Indicates the type of value unit.
[4029] Fix | Delete
* @type String
[4030] Fix | Delete
* @property type
[4031] Fix | Delete
*/
[4032] Fix | Delete
this.type = "unknown";
[4033] Fix | Delete
[4034] Fix | Delete
//figure out what type of data it is
[4035] Fix | Delete
[4036] Fix | Delete
var temp;
[4037] Fix | Delete
[4038] Fix | Delete
//it is a measurement?
[4039] Fix | Delete
if (/^([+\-]?[\d\.]+)([a-z]+)$/i.test(text)) { //dimension
[4040] Fix | Delete
this.type = "dimension";
[4041] Fix | Delete
this.value = +RegExp.$1;
[4042] Fix | Delete
this.units = RegExp.$2;
[4043] Fix | Delete
[4044] Fix | Delete
//try to narrow down
[4045] Fix | Delete
switch (this.units.toLowerCase()) {
[4046] Fix | Delete
[4047] Fix | Delete
case "em":
[4048] Fix | Delete
case "rem":
[4049] Fix | Delete
case "ex":
[4050] Fix | Delete
case "px":
[4051] Fix | Delete
case "cm":
[4052] Fix | Delete
case "mm":
[4053] Fix | Delete
case "in":
[4054] Fix | Delete
case "pt":
[4055] Fix | Delete
case "pc":
[4056] Fix | Delete
case "ch":
[4057] Fix | Delete
case "vh":
[4058] Fix | Delete
case "vw":
[4059] Fix | Delete
case "vmax":
[4060] Fix | Delete
case "vmin":
[4061] Fix | Delete
this.type = "length";
[4062] Fix | Delete
break;
[4063] Fix | Delete
[4064] Fix | Delete
case "fr":
[4065] Fix | Delete
this.type = "grid";
[4066] Fix | Delete
break;
[4067] Fix | Delete
[4068] Fix | Delete
case "deg":
[4069] Fix | Delete
case "rad":
[4070] Fix | Delete
case "grad":
[4071] Fix | Delete
case "turn":
[4072] Fix | Delete
this.type = "angle";
[4073] Fix | Delete
break;
[4074] Fix | Delete
[4075] Fix | Delete
case "ms":
[4076] Fix | Delete
case "s":
[4077] Fix | Delete
this.type = "time";
[4078] Fix | Delete
break;
[4079] Fix | Delete
[4080] Fix | Delete
case "hz":
[4081] Fix | Delete
case "khz":
[4082] Fix | Delete
this.type = "frequency";
[4083] Fix | Delete
break;
[4084] Fix | Delete
[4085] Fix | Delete
case "dpi":
[4086] Fix | Delete
case "dpcm":
[4087] Fix | Delete
this.type = "resolution";
[4088] Fix | Delete
break;
[4089] Fix | Delete
[4090] Fix | Delete
//default
[4091] Fix | Delete
[4092] Fix | Delete
}
[4093] Fix | Delete
[4094] Fix | Delete
} else if (/^([+\-]?[\d\.]+)%$/i.test(text)) { //percentage
[4095] Fix | Delete
this.type = "percentage";
[4096] Fix | Delete
this.value = +RegExp.$1;
[4097] Fix | Delete
} else if (/^([+\-]?\d+)$/i.test(text)) { //integer
[4098] Fix | Delete
this.type = "integer";
[4099] Fix | Delete
this.value = +RegExp.$1;
[4100] Fix | Delete
} else if (/^([+\-]?[\d\.]+)$/i.test(text)) { //number
[4101] Fix | Delete
this.type = "number";
[4102] Fix | Delete
this.value = +RegExp.$1;
[4103] Fix | Delete
[4104] Fix | Delete
} else if (/^#([a-f0-9]{3,6})/i.test(text)) { //hexcolor
[4105] Fix | Delete
this.type = "color";
[4106] Fix | Delete
temp = RegExp.$1;
[4107] Fix | Delete
if (temp.length === 3) {
[4108] Fix | Delete
this.red = parseInt(temp.charAt(0)+temp.charAt(0), 16);
[4109] Fix | Delete
this.green = parseInt(temp.charAt(1)+temp.charAt(1), 16);
[4110] Fix | Delete
this.blue = parseInt(temp.charAt(2)+temp.charAt(2), 16);
[4111] Fix | Delete
} else {
[4112] Fix | Delete
this.red = parseInt(temp.substring(0, 2), 16);
[4113] Fix | Delete
this.green = parseInt(temp.substring(2, 4), 16);
[4114] Fix | Delete
this.blue = parseInt(temp.substring(4, 6), 16);
[4115] Fix | Delete
}
[4116] Fix | Delete
} else if (/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/i.test(text)) { //rgb() color with absolute numbers
[4117] Fix | Delete
this.type = "color";
[4118] Fix | Delete
this.red = +RegExp.$1;
[4119] Fix | Delete
this.green = +RegExp.$2;
[4120] Fix | Delete
this.blue = +RegExp.$3;
[4121] Fix | Delete
} else if (/^rgb\(\s*(\d+)%\s*,\s*(\d+)%\s*,\s*(\d+)%\s*\)/i.test(text)) { //rgb() color with percentages
[4122] Fix | Delete
this.type = "color";
[4123] Fix | Delete
this.red = +RegExp.$1 * 255 / 100;
[4124] Fix | Delete
this.green = +RegExp.$2 * 255 / 100;
[4125] Fix | Delete
this.blue = +RegExp.$3 * 255 / 100;
[4126] Fix | Delete
} else if (/^rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*([\d\.]+)\s*\)/i.test(text)) { //rgba() color with absolute numbers
[4127] Fix | Delete
this.type = "color";
[4128] Fix | Delete
this.red = +RegExp.$1;
[4129] Fix | Delete
this.green = +RegExp.$2;
[4130] Fix | Delete
this.blue = +RegExp.$3;
[4131] Fix | Delete
this.alpha = +RegExp.$4;
[4132] Fix | Delete
} else if (/^rgba\(\s*(\d+)%\s*,\s*(\d+)%\s*,\s*(\d+)%\s*,\s*([\d\.]+)\s*\)/i.test(text)) { //rgba() color with percentages
[4133] Fix | Delete
this.type = "color";
[4134] Fix | Delete
this.red = +RegExp.$1 * 255 / 100;
[4135] Fix | Delete
this.green = +RegExp.$2 * 255 / 100;
[4136] Fix | Delete
this.blue = +RegExp.$3 * 255 / 100;
[4137] Fix | Delete
this.alpha = +RegExp.$4;
[4138] Fix | Delete
} else if (/^hsl\(\s*(\d+)\s*,\s*(\d+)%\s*,\s*(\d+)%\s*\)/i.test(text)) { //hsl()
[4139] Fix | Delete
this.type = "color";
[4140] Fix | Delete
this.hue = +RegExp.$1;
[4141] Fix | Delete
this.saturation = +RegExp.$2 / 100;
[4142] Fix | Delete
this.lightness = +RegExp.$3 / 100;
[4143] Fix | Delete
} else if (/^hsla\(\s*(\d+)\s*,\s*(\d+)%\s*,\s*(\d+)%\s*,\s*([\d\.]+)\s*\)/i.test(text)) { //hsla() color with percentages
[4144] Fix | Delete
this.type = "color";
[4145] Fix | Delete
this.hue = +RegExp.$1;
[4146] Fix | Delete
this.saturation = +RegExp.$2 / 100;
[4147] Fix | Delete
this.lightness = +RegExp.$3 / 100;
[4148] Fix | Delete
this.alpha = +RegExp.$4;
[4149] Fix | Delete
} else if (/^url\(("([^\\"]|\\.)*")\)/i.test(text)) { //URI
[4150] Fix | Delete
// generated by TokenStream.readURI, so always double-quoted.
[4151] Fix | Delete
this.type = "uri";
[4152] Fix | Delete
this.uri = PropertyValuePart.parseString(RegExp.$1);
[4153] Fix | Delete
} else if (/^([^\(]+)\(/i.test(text)) {
[4154] Fix | Delete
this.type = "function";
[4155] Fix | Delete
this.name = RegExp.$1;
[4156] Fix | Delete
this.value = text;
[4157] Fix | Delete
} else if (/^"([^\n\r\f\\"]|\\\r\n|\\[^\r0-9a-f]|\\[0-9a-f]{1,6}(\r\n|[ \n\r\t\f])?)*"/i.test(text)) { //double-quoted string
[4158] Fix | Delete
this.type = "string";
[4159] Fix | Delete
this.value = PropertyValuePart.parseString(text);
[4160] Fix | Delete
} else if (/^'([^\n\r\f\\']|\\\r\n|\\[^\r0-9a-f]|\\[0-9a-f]{1,6}(\r\n|[ \n\r\t\f])?)*'/i.test(text)) { //single-quoted string
[4161] Fix | Delete
this.type = "string";
[4162] Fix | Delete
this.value = PropertyValuePart.parseString(text);
[4163] Fix | Delete
} else if (Colors[text.toLowerCase()]) { //named color
[4164] Fix | Delete
this.type = "color";
[4165] Fix | Delete
temp = Colors[text.toLowerCase()].substring(1);
[4166] Fix | Delete
this.red = parseInt(temp.substring(0, 2), 16);
[4167] Fix | Delete
this.green = parseInt(temp.substring(2, 4), 16);
[4168] Fix | Delete
this.blue = parseInt(temp.substring(4, 6), 16);
[4169] Fix | Delete
} else if (/^[,\/]$/.test(text)) {
[4170] Fix | Delete
this.type = "operator";
[4171] Fix | Delete
this.value = text;
[4172] Fix | Delete
} else if (/^-?[a-z_\u00A0-\uFFFF][a-z0-9\-_\u00A0-\uFFFF]*$/i.test(text)) {
[4173] Fix | Delete
this.type = "identifier";
[4174] Fix | Delete
this.value = text;
[4175] Fix | Delete
}
[4176] Fix | Delete
[4177] Fix | Delete
// There can be ambiguity with escape sequences in identifiers, as
[4178] Fix | Delete
// well as with "color" parts which are also "identifiers", so record
[4179] Fix | Delete
// an explicit hint when the token generating this PropertyValuePart
[4180] Fix | Delete
// was an identifier.
[4181] Fix | Delete
this.wasIdent = Boolean(hint.ident);
[4182] Fix | Delete
[4183] Fix | Delete
}
[4184] Fix | Delete
[4185] Fix | Delete
PropertyValuePart.prototype = new SyntaxUnit();
[4186] Fix | Delete
PropertyValuePart.prototype.constructor = PropertyValuePart;
[4187] Fix | Delete
[4188] Fix | Delete
/**
[4189] Fix | Delete
* Helper method to parse a CSS string.
[4190] Fix | Delete
*/
[4191] Fix | Delete
PropertyValuePart.parseString = function(str) {
[4192] Fix | Delete
str = str.slice(1, -1); // Strip surrounding single/double quotes
[4193] Fix | Delete
var replacer = function(match, esc) {
[4194] Fix | Delete
if (/^(\n|\r\n|\r|\f)$/.test(esc)) {
[4195] Fix | Delete
return "";
[4196] Fix | Delete
}
[4197] Fix | Delete
var m = /^[0-9a-f]{1,6}/i.exec(esc);
[4198] Fix | Delete
if (m) {
[4199] Fix | Delete
var codePoint = parseInt(m[0], 16);
[4200] Fix | Delete
if (String.fromCodePoint) {
[4201] Fix | Delete
return String.fromCodePoint(codePoint);
[4202] Fix | Delete
} else {
[4203] Fix | Delete
// XXX No support for surrogates on old JavaScript engines.
[4204] Fix | Delete
return String.fromCharCode(codePoint);
[4205] Fix | Delete
}
[4206] Fix | Delete
}
[4207] Fix | Delete
return esc;
[4208] Fix | Delete
};
[4209] Fix | Delete
return str.replace(/\\(\r\n|[^\r0-9a-f]|[0-9a-f]{1,6}(\r\n|[ \n\r\t\f])?)/ig,
[4210] Fix | Delete
replacer);
[4211] Fix | Delete
};
[4212] Fix | Delete
[4213] Fix | Delete
/**
[4214] Fix | Delete
* Helper method to serialize a CSS string.
[4215] Fix | Delete
*/
[4216] Fix | Delete
PropertyValuePart.serializeString = function(value) {
[4217] Fix | Delete
var replacer = function(match, c) {
[4218] Fix | Delete
if (c === "\"") {
[4219] Fix | Delete
return "\\" + c;
[4220] Fix | Delete
}
[4221] Fix | Delete
var cp = String.codePointAt ? String.codePointAt(0) :
[4222] Fix | Delete
// We only escape non-surrogate chars, so using charCodeAt
[4223] Fix | Delete
// is harmless here.
[4224] Fix | Delete
String.charCodeAt(0);
[4225] Fix | Delete
return "\\" + cp.toString(16) + " ";
[4226] Fix | Delete
};
[4227] Fix | Delete
return "\"" + value.replace(/["\r\n\f]/g, replacer) + "\"";
[4228] Fix | Delete
};
[4229] Fix | Delete
[4230] Fix | Delete
/**
[4231] Fix | Delete
* Create a new syntax unit based solely on the given token.
[4232] Fix | Delete
* Convenience method for creating a new syntax unit when
[4233] Fix | Delete
* it represents a single token instead of multiple.
[4234] Fix | Delete
* @param {Object} token The token object to represent.
[4235] Fix | Delete
* @return {parserlib.css.PropertyValuePart} The object representing the token.
[4236] Fix | Delete
* @static
[4237] Fix | Delete
* @method fromToken
[4238] Fix | Delete
*/
[4239] Fix | Delete
PropertyValuePart.fromToken = function(token) {
[4240] Fix | Delete
var part = new PropertyValuePart(token.value, token.startLine, token.startCol, {
[4241] Fix | Delete
// Tokens can have escaped characters that would fool the type
[4242] Fix | Delete
// identification in the PropertyValuePart constructor, so pass
[4243] Fix | Delete
// in a hint if this was an identifier.
[4244] Fix | Delete
ident: token.type === Tokens.IDENT
[4245] Fix | Delete
});
[4246] Fix | Delete
return part;
[4247] Fix | Delete
};
[4248] Fix | Delete
[4249] Fix | Delete
},{"../util/SyntaxUnit":26,"./Colors":1,"./Parser":6,"./Tokens":18}],12:[function(require,module,exports){
[4250] Fix | Delete
"use strict";
[4251] Fix | Delete
[4252] Fix | Delete
var Pseudos = module.exports = {
[4253] Fix | Delete
__proto__: null,
[4254] Fix | Delete
":first-letter": 1,
[4255] Fix | Delete
":first-line": 1,
[4256] Fix | Delete
":before": 1,
[4257] Fix | Delete
":after": 1
[4258] Fix | Delete
};
[4259] Fix | Delete
[4260] Fix | Delete
Pseudos.ELEMENT = 1;
[4261] Fix | Delete
Pseudos.CLASS = 2;
[4262] Fix | Delete
[4263] Fix | Delete
Pseudos.isElement = function(pseudo) {
[4264] Fix | Delete
return pseudo.indexOf("::") === 0 || Pseudos[pseudo.toLowerCase()] === Pseudos.ELEMENT;
[4265] Fix | Delete
};
[4266] Fix | Delete
[4267] Fix | Delete
},{}],13:[function(require,module,exports){
[4268] Fix | Delete
"use strict";
[4269] Fix | Delete
[4270] Fix | Delete
module.exports = Selector;
[4271] Fix | Delete
[4272] Fix | Delete
var SyntaxUnit = require("../util/SyntaxUnit");
[4273] Fix | Delete
[4274] Fix | Delete
var Parser = require("./Parser");
[4275] Fix | Delete
var Specificity = require("./Specificity");
[4276] Fix | Delete
[4277] Fix | Delete
/**
[4278] Fix | Delete
* Represents an entire single selector, including all parts but not
[4279] Fix | Delete
* including multiple selectors (those separated by commas).
[4280] Fix | Delete
* @namespace parserlib.css
[4281] Fix | Delete
* @class Selector
[4282] Fix | Delete
* @extends parserlib.util.SyntaxUnit
[4283] Fix | Delete
* @constructor
[4284] Fix | Delete
* @param {Array} parts Array of selectors parts making up this selector.
[4285] Fix | Delete
* @param {int} line The line of text on which the unit resides.
[4286] Fix | Delete
* @param {int} col The column of text on which the unit resides.
[4287] Fix | Delete
*/
[4288] Fix | Delete
function Selector(parts, line, col) {
[4289] Fix | Delete
[4290] Fix | Delete
SyntaxUnit.call(this, parts.join(" "), line, col, Parser.SELECTOR_TYPE);
[4291] Fix | Delete
[4292] Fix | Delete
/**
[4293] Fix | Delete
* The parts that make up the selector.
[4294] Fix | Delete
* @type Array
[4295] Fix | Delete
* @property parts
[4296] Fix | Delete
*/
[4297] Fix | Delete
this.parts = parts;
[4298] Fix | Delete
[4299] Fix | Delete
/**
[4300] Fix | Delete
* The specificity of the selector.
[4301] Fix | Delete
* @type parserlib.css.Specificity
[4302] Fix | Delete
* @property specificity
[4303] Fix | Delete
*/
[4304] Fix | Delete
this.specificity = Specificity.calculate(this);
[4305] Fix | Delete
[4306] Fix | Delete
}
[4307] Fix | Delete
[4308] Fix | Delete
Selector.prototype = new SyntaxUnit();
[4309] Fix | Delete
Selector.prototype.constructor = Selector;
[4310] Fix | Delete
[4311] Fix | Delete
[4312] Fix | Delete
},{"../util/SyntaxUnit":26,"./Parser":6,"./Specificity":16}],14:[function(require,module,exports){
[4313] Fix | Delete
"use strict";
[4314] Fix | Delete
[4315] Fix | Delete
module.exports = SelectorPart;
[4316] Fix | Delete
[4317] Fix | Delete
var SyntaxUnit = require("../util/SyntaxUnit");
[4318] Fix | Delete
[4319] Fix | Delete
var Parser = require("./Parser");
[4320] Fix | Delete
[4321] Fix | Delete
/**
[4322] Fix | Delete
* Represents a single part of a selector string, meaning a single set of
[4323] Fix | Delete
* element name and modifiers. This does not include combinators such as
[4324] Fix | Delete
* spaces, +, >, etc.
[4325] Fix | Delete
* @namespace parserlib.css
[4326] Fix | Delete
* @class SelectorPart
[4327] Fix | Delete
* @extends parserlib.util.SyntaxUnit
[4328] Fix | Delete
* @constructor
[4329] Fix | Delete
* @param {String} elementName The element name in the selector or null
[4330] Fix | Delete
* if there is no element name.
[4331] Fix | Delete
* @param {Array} modifiers Array of individual modifiers for the element.
[4332] Fix | Delete
* May be empty if there are none.
[4333] Fix | Delete
* @param {String} text The text representation of the unit.
[4334] Fix | Delete
* @param {int} line The line of text on which the unit resides.
[4335] Fix | Delete
* @param {int} col The column of text on which the unit resides.
[4336] Fix | Delete
*/
[4337] Fix | Delete
function SelectorPart(elementName, modifiers, text, line, col) {
[4338] Fix | Delete
[4339] Fix | Delete
SyntaxUnit.call(this, text, line, col, Parser.SELECTOR_PART_TYPE);
[4340] Fix | Delete
[4341] Fix | Delete
/**
[4342] Fix | Delete
* The tag name of the element to which this part
[4343] Fix | Delete
* of the selector affects.
[4344] Fix | Delete
* @type String
[4345] Fix | Delete
* @property elementName
[4346] Fix | Delete
*/
[4347] Fix | Delete
this.elementName = elementName;
[4348] Fix | Delete
[4349] Fix | Delete
/**
[4350] Fix | Delete
* The parts that come after the element name, such as class names, IDs,
[4351] Fix | Delete
* pseudo classes/elements, etc.
[4352] Fix | Delete
* @type Array
[4353] Fix | Delete
* @property modifiers
[4354] Fix | Delete
*/
[4355] Fix | Delete
this.modifiers = modifiers;
[4356] Fix | Delete
[4357] Fix | Delete
}
[4358] Fix | Delete
[4359] Fix | Delete
SelectorPart.prototype = new SyntaxUnit();
[4360] Fix | Delete
SelectorPart.prototype.constructor = SelectorPart;
[4361] Fix | Delete
[4362] Fix | Delete
[4363] Fix | Delete
},{"../util/SyntaxUnit":26,"./Parser":6}],15:[function(require,module,exports){
[4364] Fix | Delete
"use strict";
[4365] Fix | Delete
[4366] Fix | Delete
module.exports = SelectorSubPart;
[4367] Fix | Delete
[4368] Fix | Delete
var SyntaxUnit = require("../util/SyntaxUnit");
[4369] Fix | Delete
[4370] Fix | Delete
var Parser = require("./Parser");
[4371] Fix | Delete
[4372] Fix | Delete
/**
[4373] Fix | Delete
* Represents a selector modifier string, meaning a class name, element name,
[4374] Fix | Delete
* element ID, pseudo rule, etc.
[4375] Fix | Delete
* @namespace parserlib.css
[4376] Fix | Delete
* @class SelectorSubPart
[4377] Fix | Delete
* @extends parserlib.util.SyntaxUnit
[4378] Fix | Delete
* @constructor
[4379] Fix | Delete
* @param {String} text The text representation of the unit.
[4380] Fix | Delete
* @param {String} type The type of selector modifier.
[4381] Fix | Delete
* @param {int} line The line of text on which the unit resides.
[4382] Fix | Delete
* @param {int} col The column of text on which the unit resides.
[4383] Fix | Delete
*/
[4384] Fix | Delete
function SelectorSubPart(text, type, line, col) {
[4385] Fix | Delete
[4386] Fix | Delete
SyntaxUnit.call(this, text, line, col, Parser.SELECTOR_SUB_PART_TYPE);
[4387] Fix | Delete
[4388] Fix | Delete
/**
[4389] Fix | Delete
* The type of modifier.
[4390] Fix | Delete
* @type String
[4391] Fix | Delete
* @property type
[4392] Fix | Delete
*/
[4393] Fix | Delete
this.type = type;
[4394] Fix | Delete
[4395] Fix | Delete
/**
[4396] Fix | Delete
* Some subparts have arguments, this represents them.
[4397] Fix | Delete
* @type Array
[4398] Fix | Delete
* @property args
[4399] Fix | Delete
*/
[4400] Fix | Delete
this.args = [];
[4401] Fix | Delete
[4402] Fix | Delete
}
[4403] Fix | Delete
[4404] Fix | Delete
SelectorSubPart.prototype = new SyntaxUnit();
[4405] Fix | Delete
SelectorSubPart.prototype.constructor = SelectorSubPart;
[4406] Fix | Delete
[4407] Fix | Delete
[4408] Fix | Delete
},{"../util/SyntaxUnit":26,"./Parser":6}],16:[function(require,module,exports){
[4409] Fix | Delete
"use strict";
[4410] Fix | Delete
[4411] Fix | Delete
module.exports = Specificity;
[4412] Fix | Delete
[4413] Fix | Delete
var Pseudos = require("./Pseudos");
[4414] Fix | Delete
var SelectorPart = require("./SelectorPart");
[4415] Fix | Delete
[4416] Fix | Delete
/**
[4417] Fix | Delete
* Represents a selector's specificity.
[4418] Fix | Delete
* @namespace parserlib.css
[4419] Fix | Delete
* @class Specificity
[4420] Fix | Delete
* @constructor
[4421] Fix | Delete
* @param {int} a Should be 1 for inline styles, zero for stylesheet styles
[4422] Fix | Delete
* @param {int} b Number of ID selectors
[4423] Fix | Delete
* @param {int} c Number of classes and pseudo classes
[4424] Fix | Delete
* @param {int} d Number of element names and pseudo elements
[4425] Fix | Delete
*/
[4426] Fix | Delete
function Specificity(a, b, c, d) {
[4427] Fix | Delete
this.a = a;
[4428] Fix | Delete
this.b = b;
[4429] Fix | Delete
this.c = c;
[4430] Fix | Delete
this.d = d;
[4431] Fix | Delete
}
[4432] Fix | Delete
[4433] Fix | Delete
Specificity.prototype = {
[4434] Fix | Delete
constructor: Specificity,
[4435] Fix | Delete
[4436] Fix | Delete
/**
[4437] Fix | Delete
* Compare this specificity to another.
[4438] Fix | Delete
* @param {Specificity} other The other specificity to compare to.
[4439] Fix | Delete
* @return {int} -1 if the other specificity is larger, 1 if smaller, 0 if equal.
[4440] Fix | Delete
* @method compare
[4441] Fix | Delete
*/
[4442] Fix | Delete
compare: function(other) {
[4443] Fix | Delete
var comps = ["a", "b", "c", "d"],
[4444] Fix | Delete
i, len;
[4445] Fix | Delete
[4446] Fix | Delete
for (i=0, len=comps.length; i < len; i++) {
[4447] Fix | Delete
if (this[comps[i]] < other[comps[i]]) {
[4448] Fix | Delete
return -1;
[4449] Fix | Delete
} else if (this[comps[i]] > other[comps[i]]) {
[4450] Fix | Delete
return 1;
[4451] Fix | Delete
}
[4452] Fix | Delete
}
[4453] Fix | Delete
[4454] Fix | Delete
return 0;
[4455] Fix | Delete
},
[4456] Fix | Delete
[4457] Fix | Delete
/**
[4458] Fix | Delete
* Creates a numeric value for the specificity.
[4459] Fix | Delete
* @return {int} The numeric value for the specificity.
[4460] Fix | Delete
* @method valueOf
[4461] Fix | Delete
*/
[4462] Fix | Delete
valueOf: function() {
[4463] Fix | Delete
return (this.a * 1000) + (this.b * 100) + (this.c * 10) + this.d;
[4464] Fix | Delete
},
[4465] Fix | Delete
[4466] Fix | Delete
/**
[4467] Fix | Delete
* Returns a string representation for specificity.
[4468] Fix | Delete
* @return {String} The string representation of specificity.
[4469] Fix | Delete
* @method toString
[4470] Fix | Delete
*/
[4471] Fix | Delete
toString: function() {
[4472] Fix | Delete
return this.a + "," + this.b + "," + this.c + "," + this.d;
[4473] Fix | Delete
}
[4474] Fix | Delete
[4475] Fix | Delete
};
[4476] Fix | Delete
[4477] Fix | Delete
/**
[4478] Fix | Delete
* Calculates the specificity of the given selector.
[4479] Fix | Delete
* @param {parserlib.css.Selector} The selector to calculate specificity for.
[4480] Fix | Delete
* @return {parserlib.css.Specificity} The specificity of the selector.
[4481] Fix | Delete
* @static
[4482] Fix | Delete
* @method calculate
[4483] Fix | Delete
*/
[4484] Fix | Delete
Specificity.calculate = function(selector) {
[4485] Fix | Delete
[4486] Fix | Delete
var i, len,
[4487] Fix | Delete
part,
[4488] Fix | Delete
b=0, c=0, d=0;
[4489] Fix | Delete
[4490] Fix | Delete
function updateValues(part) {
[4491] Fix | Delete
[4492] Fix | Delete
var i, j, len, num,
[4493] Fix | Delete
elementName = part.elementName ? part.elementName.text : "",
[4494] Fix | Delete
modifier;
[4495] Fix | Delete
[4496] Fix | Delete
if (elementName && elementName.charAt(elementName.length-1) !== "*") {
[4497] Fix | Delete
d++;
[4498] Fix | Delete
}
[4499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function