Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: webkit properties not being recognized #112

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions lib/CSSStyleDeclaration.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -553,4 +553,20 @@ describe('CSSStyleDeclaration', () => {
style.setProperty('width', 'calc(100% - 100px)');
expect(style.getPropertyValue('width')).toEqual('calc(100% - 100px)');
});

test('implements webkitTextFillColor', () => {
const style = new CSSStyleDeclaration();
style.setProperty('-webkit-text-fill-color', '#ffffff66');

expect(style.webkitTextFillColor).toEqual('rgba(255, 255, 255, 0.4)');
});

test('vendor property with cssText', () => {
const style = new CSSStyleDeclaration();
style.cssText = '-webkit-line-clamp: 20';

// TODO: this should be a number
expect(style.WebkitLineClamp).toEqual('20');
expect(style.getPropertyValue('-webkit-line-clamp')).toEqual('20');
});
});
2 changes: 1 addition & 1 deletion lib/allWebkitProperties.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,4 +191,4 @@ module.exports = [
'wrap-through',
'writing-mode',
'zoom',
].map(prop => 'webkit-' + prop);
].map(prop => '-webkit-' + prop);
11 changes: 9 additions & 2 deletions scripts/generate_implemented_properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,15 @@ const camelToDashed = require('../lib/parsers').camelToDashed;
const dashedProperties = fs
.readdirSync(path.resolve(__dirname, '../lib/properties'))
.filter(propertyFile => propertyFile.substr(-3) === '.js')
.map(propertyFile => camelToDashed(propertyFile.replace('.js', '')));

.map(propertyFile => camelToDashed(propertyFile.replace('.js', '')))
.map(property => {
const isVendorSpecific = /^(o|moz|ms|webkit)-/.test(property);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sneaking in support for other vendor prefixes. I'm not sure if you're opinionated about other vendor prefixes. I'm looking at this purely from a testing perspective where I'd like to see support for all vendor prefixes. Otherwise it's hard to write tests that cover all browsers at once.

Copy link

@ExE-Boss ExE-Boss Apr 1, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The real bug is in:

var first_segment = /^\([^-]\)-/;

It should be:

var first_segment = /^([^-]+)-/;

That’s what I’m doing in #116.


P.S.: JSDOM projects don't use the Angular commit style.

if (isVendorSpecific) {
return '-' + property;
} else {
return property;
}
});
const out_file = fs.createWriteStream(path.resolve(__dirname, '../lib/implementedProperties.js'), {
encoding: 'utf-8',
});
Expand Down
4 changes: 4 additions & 0 deletions scripts/generate_properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,10 @@ parsedFiles.forEach(function(file) {
var propertyDefinitions = [];
parsedFiles.forEach(function(file) {
var dashed = camelToDashed(file.property);
var isVendorSpecific = /^(o|moz|ms|webkit)-/.test(dashed);
if (isVendorSpecific) {
dashed = '-' + dashed;
}
propertyDefinitions.push(
t.objectProperty(
t.identifier(file.property),
Expand Down