MCPcopy Create free account
hub / github.com/Vishal-raj-1/Awesome-JavaScript-Projects / parse

Function parse

assets/js/avatarMaker_js/html2canvas.js:4156–4188  ·  view source on GitHub ↗
(descriptor, style)

Source from the content-addressed store, hash-verified

4154 }());
4155 // eslint-disable-next-line @typescript-eslint/no-explicit-any
4156 var parse = function (descriptor, style) {
4157 var tokenizer = new Tokenizer();
4158 var value = style !== null && typeof style !== 'undefined' ? style.toString() : descriptor.initialValue;
4159 tokenizer.write(value);
4160 var parser = new Parser(tokenizer.read());
4161 switch (descriptor.type) {
4162 case PropertyDescriptorParsingType.IDENT_VALUE:
4163 var token = parser.parseComponentValue();
4164 return descriptor.parse(isIdentToken(token) ? token.value : descriptor.initialValue);
4165 case PropertyDescriptorParsingType.VALUE:
4166 return descriptor.parse(parser.parseComponentValue());
4167 case PropertyDescriptorParsingType.LIST:
4168 return descriptor.parse(parser.parseComponentValues());
4169 case PropertyDescriptorParsingType.TOKEN_VALUE:
4170 return parser.parseComponentValue();
4171 case PropertyDescriptorParsingType.TYPE_VALUE:
4172 switch (descriptor.format) {
4173 case 'angle':
4174 return angle.parse(parser.parseComponentValue());
4175 case 'color':
4176 return color.parse(parser.parseComponentValue());
4177 case 'image':
4178 return image.parse(parser.parseComponentValue());
4179 case 'length':
4180 var length_1 = parser.parseComponentValue();
4181 return isLength(length_1) ? length_1 : ZERO_LENGTH;
4182 case 'length-percentage':
4183 var value_1 = parser.parseComponentValue();
4184 return isLengthPercentage(value_1) ? value_1 : ZERO_LENGTH;
4185 }
4186 }
4187 throw new Error("Attempting to parse unsupported css format type " + descriptor.format);
4188 };
4189
4190 var ElementContainer = /** @class */ (function () {
4191 function ElementContainer(element) {

Callers 3

CSSParsedDeclarationFunction · 0.85

Calls 3

isIdentTokenFunction · 0.85
isLengthFunction · 0.85
isLengthPercentageFunction · 0.85

Tested by

no test coverage detected