react / wstein / node_modules / jest-cli / node_modules / jsdom / node_modules / cssstyle / scripts / generate_properties.js
81141 views'use strict';12var fs = require('fs');3var path = require('path');45var camelToDashed = require('../lib/parsers').camelToDashed;67var property_files = fs.readdirSync(path.resolve(__dirname, '../lib/properties'));8var out_file = fs.createWriteStream(path.resolve(__dirname, '../lib/properties.js'), {encoding: 'utf-8'});910out_file.write('\'use strict\';\n\n// autogenerated\n\n');11out_file.write('/*\n *\n * http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSS2Properties\n */\n\n');12out_file.write('module.exports = function (prototype) {\n');1314property_files.forEach(function (property) {15var dashed;16if (property.substr(-3) === '.js') {17property = path.basename(property, '.js');18dashed = camelToDashed(property);19out_file.write(' Object.defineProperty(prototype, \'' + property + '\', {\n');20out_file.write(' get: function () {\n');21out_file.write(' var definition = require(\'./properties/' + property + '\').definition;\n');22out_file.write(' Object.defineProperty(prototype, \'' + property + '\', definition);\n');23out_file.write(' return this.' + property + ';\n');24out_file.write(' },\n');25out_file.write(' set: function (v) {\n');26out_file.write(' var definition = require(\'./properties/' + property + '\').definition;\n');27out_file.write(' Object.defineProperty(prototype, \'' + property + '\', definition);\n');28out_file.write(' this.' + property + ' = v;\n');29out_file.write(' },\n');30out_file.write(' enumerable: true,\n');31out_file.write(' configurable: true\n');32out_file.write(' });\n');33if (property !== dashed) {34out_file.write(' Object.defineProperty(prototype, \'' + dashed + '\', {\n');35out_file.write(' get: function () {\n');36out_file.write(' var definition = require(\'./properties/' + property + '\').definition;\n');37out_file.write(' Object.defineProperty(prototype, \'' + property + '\', definition);\n');38out_file.write(' return this.' + property + ';\n');39out_file.write(' },\n');40out_file.write(' set: function (v) {\n');41out_file.write(' var definition = require(\'./properties/' + property + '\').definition;\n');42out_file.write(' Object.defineProperty(prototype, \'' + property + '\', definition);\n');43out_file.write(' this.' + property + ' = v;\n');44out_file.write(' },\n');45out_file.write(' enumerable: true,\n');46out_file.write(' configurable: true\n');47out_file.write(' });\n');48}49}50});5152out_file.write('};\n');53out_file.end(function (err) {54if (err) {55throw err;56}57});585960