Skip to content

Commit 50d66c8

Browse files
committed
Fix webkit‑cased property descriptors
1 parent 7156c3f commit 50d66c8

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

lib/CSSStyleDeclaration-impl.js

+7
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,13 @@ allExtraProperties.forEach(function(property) {
244244
cssPropertyToIDLAttribute(property),
245245
declaration
246246
);
247+
if (property.startsWith('-webkit-')) {
248+
Object.defineProperty(
249+
CSSStyleDeclarationImpl.prototype,
250+
cssPropertyToIDLAttribute(property, /* lowercaseFirst = */ true),
251+
declaration
252+
);
253+
}
247254
}
248255
});
249256

scripts/generate_properties.js

+14-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ var generate = require('babel-generator').default;
88
var traverse = require('babel-traverse').default;
99
var resolve = require('resolve');
1010

11-
var { idlAttributeToCSSProperty } = require('../lib/parsers');
11+
var { idlAttributeToCSSProperty, cssPropertyToIDLAttribute } = require('../lib/parsers');
1212

1313
var basename = path.basename;
1414
var dirname = path.dirname;
@@ -56,12 +56,17 @@ function isRequire(node, filename) {
5656
}
5757
}
5858

59+
const webkitPropertyName = /^webkit[A-Z]/;
60+
5961
// step 1: parse all files and figure out their dependencies
6062
var parsedFilesByPath = {};
6163
property_files.map(function(property) {
6264
var filename = path.resolve(__dirname, '../lib/properties/' + property);
6365
var src = fs.readFileSync(filename, 'utf8');
6466
property = basename(property, '.js');
67+
if (webkitPropertyName.test(property)) {
68+
property = property[0].toUpperCase() + property.substring(1);
69+
}
6570
var ast = babylon.parse(src);
6671
var dependencies = [];
6772
traverse(ast, {
@@ -261,6 +266,14 @@ parsedFiles.forEach(function(file) {
261266
t.identifier(file.property + '_export_definition')
262267
)
263268
);
269+
if (dashed.startsWith('-webkit-')) {
270+
propertyDefinitions.push(
271+
t.objectProperty(
272+
t.identifier(cssPropertyToIDLAttribute(dashed, /* lowercaseFirst = */ true)),
273+
t.identifier(file.property + '_export_definition')
274+
)
275+
);
276+
}
264277
if (file.property !== dashed) {
265278
propertyDefinitions.push(
266279
t.objectProperty(t.stringLiteral(dashed), t.identifier(file.property + '_export_definition'))

0 commit comments

Comments
 (0)