Skip to content
This repository was archived by the owner on Dec 4, 2017. It is now read-only.

Commit 6962f03

Browse files
Foxandxsswardbell
authored andcommitted
chore: add _self target to embedded plunkers (#2201)
1 parent 8e15829 commit 6962f03

File tree

2 files changed

+9
-15
lines changed

2 files changed

+9
-15
lines changed

public/resources/js/directives/live-example.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ angularIO.directive('liveExample', ['$location', function ($location) {
3232

3333
function span(text) { return '<span>' + text + '</span>'; }
3434

35-
function embeddedTemplate(src, name) {
35+
function embeddedTemplate(src) {
3636
return '<div ng-if="embeddedShow">' +
37-
'<iframe frameborder="0" width="100%" height="100%" name="' + name + '" src="' + src + '"></iframe>' +
37+
'<iframe frameborder="0" width="100%" height="100%" src="' + src + '"></iframe>' +
3838
'</div>' +
3939
'<img ng-click="toggleEmbedded()" ng-if="!embeddedShow" src="/resources/images/plunker/placeholder.png" alt="plunker">';
4040
}
@@ -57,9 +57,9 @@ angularIO.directive('liveExample', ['$location', function ($location) {
5757
var isForJs = attrs.lang === 'js' || NgIoUtil.isDoc($location, 'js');
5858
var exLang = isForDart ? 'dart' : isForJs ? 'js' : 'ts';
5959

60-
if (attrs.hasOwnProperty('embedded') && !isForDart) {
60+
if (embedded && !isForDart) {
6161
href = '/resources/live-examples/' + ex + '/' + exLang + '/' + plnkr + '.html'
62-
template = embeddedTemplate(href, plnkr);
62+
template = embeddedTemplate(href);
6363
} else {
6464
var href = isForDart
6565
? 'http://angular-examples.github.io/' + ex

tools/plunker-builder/builder.js

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class PlunkerBuilder {
8383
var config = this._initConfigAndCollectFileNames(configFileName);
8484
var postData = this._createPostData(config);
8585
this._addPlunkerFiles(config, postData);
86-
var html = this._createPlunkerHtml(postData, altFileName);
86+
var html = this._createPlunkerHtml(postData);
8787
if (this.options.writeNoLink) {
8888
fs.writeFileSync(outputFileName, html, 'utf-8');
8989
}
@@ -106,15 +106,9 @@ class PlunkerBuilder {
106106
}
107107
}
108108

109-
_createBasePlunkerHtml(embedded, altFileName) {
110-
// We extract the filename without extension
111-
var targetName = '';
112-
if (altFileName) {
113-
targetName = altFileName.split('/').pop().slice(0, -5);
114-
}
115-
var target = embedded ? targetName : '_self';
109+
_createBasePlunkerHtml(embedded) {
116110
var html = '<!DOCTYPE html><html lang="en"><body>'
117-
html += `<form id="mainForm" method="post" action="${this.options.url}" target="${target}">`
111+
html += `<form id="mainForm" method="post" action="${this.options.url}" target="_self">`
118112

119113
// html += '<div class="button"><button id="formButton" type="submit">Create Plunker</button></div>'
120114
// html += '</form><script>document.getElementById("formButton").click();</script>'
@@ -183,8 +177,8 @@ class PlunkerBuilder {
183177
return postData;
184178
}
185179

186-
_createPlunkerHtml(postData, altFileName) {
187-
var baseHtml = this._createBasePlunkerHtml(this.options.embedded, altFileName);
180+
_createPlunkerHtml(postData) {
181+
var baseHtml = this._createBasePlunkerHtml(this.options.embedded);
188182
var doc = jsdom.jsdom(baseHtml);
189183
var form = doc.querySelector('form');
190184
_.forEach(postData, (value, key) => {

0 commit comments

Comments
 (0)