source: frontend/node_modules/cssstyle/lib/properties/margin.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 1.2 KB
Line 
1'use strict';
2
3var parsers = require('../parsers.js');
4var TYPES = parsers.TYPES;
5
6var isValid = function(v) {
7 if (v.toLowerCase() === 'auto') {
8 return true;
9 }
10 var type = parsers.valueType(v);
11 return (
12 type === TYPES.LENGTH ||
13 type === TYPES.PERCENT ||
14 (type === TYPES.INTEGER && (v === '0' || v === 0))
15 );
16};
17
18var parser = function(v) {
19 var V = v.toLowerCase();
20 if (V === 'auto') {
21 return V;
22 }
23 return parsers.parseMeasurement(v);
24};
25
26var mySetter = parsers.implicitSetter('margin', '', isValid, parser);
27var myGlobal = parsers.implicitSetter(
28 'margin',
29 '',
30 function() {
31 return true;
32 },
33 function(v) {
34 return v;
35 }
36);
37
38module.exports.definition = {
39 set: function(v) {
40 if (typeof v === 'number') {
41 v = String(v);
42 }
43 if (typeof v !== 'string') {
44 return;
45 }
46 var V = v.toLowerCase();
47 switch (V) {
48 case 'inherit':
49 case 'initial':
50 case 'unset':
51 case '':
52 myGlobal.call(this, V);
53 break;
54
55 default:
56 mySetter.call(this, v);
57 break;
58 }
59 },
60 get: function() {
61 return this.getPropertyValue('margin');
62 },
63 enumerable: true,
64 configurable: true,
65};
66
67module.exports.isValid = isValid;
68module.exports.parser = parser;
Note: See TracBrowser for help on using the repository browser.