Skip to content
This repository has been archived by the owner on Feb 15, 2024. It is now read-only.

Commit

Permalink
override without special name fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Öner Zafer committed Jun 23, 2019
1 parent 4ccf9da commit 9229ec2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
7 changes: 3 additions & 4 deletions lib/extend.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@ module.exports = (dom, extendingAppManifest) => {
);
if (extendingAppManifest.overrides && extendingAppManifest.overrides.length) {
extendingAppManifest.overrides.forEach(override => {
const elem =
_$(`[public="${override.target}"]`) ||
_$(`${override.target} [public]`);
const elem = _$(`${override.tag}[public="${override.target}"]`);
let content = override.content;
const superTagPattern = /(<super\s*\/>)|(<super>.*<\/\s*super>)/g;
if (superTagPattern.test(content)) {
content = content.replace(superTagPattern, elem.innerHTML);
}
utils.replaceElement(dom, elem, override.target, content);
const tagName = override.target && override.target !== '' ? override.target : override.tag;
utils.replaceElement(dom, elem, tagName, content);
});
}
return dom;
Expand Down
5 changes: 2 additions & 3 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,8 @@ const toBundleItem = elem => ({
});

const toOverrideItem = elem => ({
target: elem.getAttribute('override')
? elem.getAttribute('override')
: elem.tagName,
tag: elem.tagName,
target: elem.getAttribute('override') || '',
content: elem.innerHTML,
});

Expand Down
6 changes: 3 additions & 3 deletions test/extend/app.html.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ exports.SomeApp = /*html*/ `
<html lang="en">
<head>
<meta export="SampleApp" extends="SomeApp1">
<title>SomeApp Title</title>
<title override>SomeApp Title</title>
<link resource href="someapp.css" rel="stylesheet" type="text/css">
</head>
<body>
Expand All @@ -16,7 +16,7 @@ exports.SomeApp1 = /*html*/ `
<html lang="en">
<head>
<meta export="SampleApp1">
<title>SomeApp1 Title</title>
<title public>SomeApp1 Title</title>
<link resource href="someapp1.css" rel="stylesheet" type="text/css">
</head>
<body>
Expand All @@ -30,7 +30,7 @@ exports.Expected = /*html*/ `
<html lang="en">
<head>
<meta export="SampleApp">
<title>SomeApp1 Title</title>
<title>SomeApp Title</title>
<link resource="resource" href="someapp1.css" rel="stylesheet" type="text/css">
<link resource="resource" href="someapp.css" rel="stylesheet" type="text/css">
</head>
Expand Down

0 comments on commit 9229ec2

Please sign in to comment.