| Leo Repp | 58b9f11 | 2021-11-22 11:57:47 +0100 | [diff] [blame^] | 1 | var mdnProperties = require('mdn-data/css/properties.json'); |
| 2 | var mdnSyntaxes = require('mdn-data/css/syntaxes.json'); |
| 3 | var patch = require('./patch.json'); |
| 4 | |
| 5 | function buildDictionary(dict, patchDict) { |
| 6 | var result = {}; |
| 7 | |
| 8 | // copy all syntaxes for an original dict |
| 9 | for (var key in dict) { |
| 10 | result[key] = dict[key].syntax; |
| 11 | } |
| 12 | |
| 13 | // apply a patch |
| 14 | for (var key in patchDict) { |
| 15 | if (key in dict) { |
| 16 | if (patchDict[key].syntax) { |
| 17 | result[key] = patchDict[key].syntax; |
| 18 | } else { |
| 19 | delete result[key]; |
| 20 | } |
| 21 | } else { |
| 22 | if (patchDict[key].syntax) { |
| 23 | result[key] = patchDict[key].syntax; |
| 24 | } |
| 25 | } |
| 26 | } |
| 27 | |
| 28 | return result; |
| 29 | } |
| 30 | |
| 31 | module.exports = { |
| 32 | properties: buildDictionary(mdnProperties, patch.properties), |
| 33 | types: buildDictionary(mdnSyntaxes, patch.syntaxes) |
| 34 | }; |