Skip to content

Commit

Permalink
Trace the complete font-family value, and don't unquote it
Browse files Browse the repository at this point in the history
  • Loading branch information
papandreou committed Jun 24, 2018
1 parent 23c0a5a commit 556cb77
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions lib/util/fonts/getTextByFontProperties.js
Original file line number Diff line number Diff line change
Expand Up @@ -1175,8 +1175,8 @@ function getTextByFontProperties(htmlAsset, memoizedGetCssRulesByProperty) {
(fontProperties && fontProperties[prop]) ||
initialValueByProp[prop];
}
if (prop === 'font-family') {
value = unquote(Array.isArray(value) ? value[0] : value);
if (prop === 'font-family' && Array.isArray(value)) {
value = value.join(', ');
}
if (value !== hypotheticalValue.value) {
styledText[prop].splice(i, 1, {
Expand Down
22 changes: 11 additions & 11 deletions test/util/fonts/getTextByFontProperties.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ describe('lib/util/fonts/getTextByFontProperties', function() {
);
});

it('should unquote single quoted font-family', function() {
it('should trace a single quoted font-family', function() {
var htmlText = [
"<style>body { font-family: 'font 1'; }</style>",
'text'
Expand All @@ -147,7 +147,7 @@ describe('lib/util/fonts/getTextByFontProperties', function() {
{
text: 'text',
props: {
'font-family': 'font 1',
'font-family': "'font 1'",
'font-weight': 'normal',
'font-style': 'normal'
}
Expand All @@ -156,7 +156,7 @@ describe('lib/util/fonts/getTextByFontProperties', function() {
);
});

it('should unquote double quoted font-family', function() {
it('should trace a double quoted font-family', function() {
var htmlText = [
'<style>body { font-family: "font 1"; }</style>',
'text'
Expand All @@ -169,7 +169,7 @@ describe('lib/util/fonts/getTextByFontProperties', function() {
{
text: 'text',
props: {
'font-family': 'font 1',
'font-family': '"font 1"',
'font-weight': 'normal',
'font-style': 'normal'
}
Expand Down Expand Up @@ -1790,15 +1790,15 @@ describe('lib/util/fonts/getTextByFontProperties', function() {
{
text: 'foo',
props: {
'font-family': 'myClass',
'font-family': '"myClass"',
'font-weight': '900',
'font-style': 'normal'
}
},
{
text: 'foo',
props: {
'font-family': 'myClass',
'font-family': '"myClass"',
'font-weight': 'normal',
'font-style': 'normal'
}
Expand Down Expand Up @@ -2805,7 +2805,7 @@ describe('lib/util/fonts/getTextByFontProperties', function() {
{
text: 'foo',
props: {
'font-family': 'famfam',
'font-family': '"famfam"',
'font-weight': 'bold',
'font-style': 'normal'
}
Expand All @@ -2827,7 +2827,7 @@ describe('lib/util/fonts/getTextByFontProperties', function() {
{
text: 'foo',
props: {
'font-family': 'famfam',
'font-family': '"famfam"',
'font-weight': 'normal',
'font-style': 'normal'
}
Expand Down Expand Up @@ -4266,7 +4266,7 @@ describe('lib/util/fonts/getTextByFontProperties', function() {
{
text: 'quux',
props: {
'font-family': 'foo',
'font-family': "'foo'",
'font-style': 'normal',
'font-weight': 'normal'
}
Expand Down Expand Up @@ -4295,7 +4295,7 @@ describe('lib/util/fonts/getTextByFontProperties', function() {
{
text: 'quux',
props: {
'font-family': 'bar',
'font-family': "'bar'",
'font-style': 'normal',
'font-weight': 'normal'
}
Expand Down Expand Up @@ -4380,7 +4380,7 @@ describe('lib/util/fonts/getTextByFontProperties', function() {
{
text: 'quux',
props: {
'font-family': 'var(--my-font)',
'font-family': "'var(--my-font)'",
'font-style': 'normal',
'font-weight': 'normal'
}
Expand Down

0 comments on commit 556cb77

Please sign in to comment.