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

Attribute parsing fix #22

Open
wants to merge 1 commit into
base: dev
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
5 changes: 4 additions & 1 deletion lib/i18n-lint.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,14 @@ I18nLint.scan = function(lines, options) {

/* @hack @todo replaces all template delimited-content with spaces (see file
* header)
* another @hack: if template delimited-content is preceded by '=' it will also
* be removed - this is not to leave attributes without a value. E.g. 'title={test}'
* needs to be converted to 'title', and not 'title='
*/
options.templateDelimiters.forEach(function(delimiters) {
if (delimiters.length === 2) {
lines = lines.replace(new RegExp(
delimiters.join('(?:.|\\n|\\r)*?'), 'g'
'=?\\s*' + delimiters.join('(?:.|\\n|\\r)*?'), 'g'
), function(match) {
return match.replace(/./g, ' ');
});
Expand Down
11 changes: 11 additions & 0 deletions test/fixtures/lwc.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<template>
<lightning-input
type="date"
data-inputable="true"
label={columnLabel}
name="dt-inline-edit-dateLocal"
variant="label-hidden"
value={editedValue}
class="datatable-inline-edit"
></lightning-input>
</template>
10 changes: 10 additions & 0 deletions test/lib/i18n-lint.js
Original file line number Diff line number Diff line change
Expand Up @@ -483,5 +483,15 @@ describe('I18nLint lib', function() {

expect(errors).to.have.length(1);
});

it('should handle attributes that are not enclosed', function() {
var errors = I18nLint('test/fixtures/lwc.html',
{ attributes: ['alt', 'placeholder', 'title', 'label', 'alternative-text', 'text'],
templateDelimiters: [['{','}']],
ignoreTags: ['style', 'script', 'pre', 'code']
});

expect(errors).to.have.length(0);
});
});