Skip to content

Custom attributes translation extracts inner html instead of attribute value #354

@aszczepanek

Description

@aszczepanek

Configuration:
{ attributes: ["title"] }

Example html:
<div title="Some hint for user"> <div>Header</div> <div>Some content to read</div> < /div>

Current implementation will extract inner html (<div>Header...) instead of title attribute value, probably because of this lines:
if (possibleAttributes.indexOf(attr) > -1) {
var attrValue = extracted[attr];
str = node.html(); // this shouldn't be necessary, but it is
self.addString(reference(n.startIndex), str || getAttr(attr) || '', attrValue.plural, attrValue.extractedComment, attrValue.context);
}

It works only for attributes on elements without closing tag like input:
<input type="text" placeholder="This text can be extracted" title="This text can also be extracted">

There is no tag so node.html() returns nothing so getAttr can execute.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions