|
37 | 37 | else if (window.getComputedStyle) {
|
38 | 38 | // getComputedStyle can return null when we're inside a hidden iframe on
|
39 | 39 | // Firefox; don't attempt to retrieve style props in this case.
|
40 |
| - // https://bugzilla.mozilla.org/show_bug.cgi?id=548397 |
| 40 | + // https://bugzilla.mozilla.org/show_bug.cgi?id=548397 |
41 | 41 | var style = document.defaultView.getComputedStyle(el, null);
|
42 | 42 | if (style)
|
43 | 43 | x = style.getPropertyValue(styleProp);
|
|
1282 | 1282 | });
|
1283 | 1283 | outputBindings.register(htmlOutputBinding, 'shiny.htmlOutput');
|
1284 | 1284 |
|
1285 |
| - // Render HTML in a DOM element, inserting singletons into head as needed |
1286 |
| - exports.renderHtml = function(html, el, dependencies) { |
| 1285 | + var renderDependencies = exports.renderDependencies = function(dependencies) { |
1287 | 1286 | if (dependencies) {
|
1288 | 1287 | $.each(dependencies, function(i, dep) {
|
1289 | 1288 | renderDependency(dep);
|
1290 | 1289 | });
|
1291 | 1290 | }
|
| 1291 | + }; |
| 1292 | + |
| 1293 | + // Render HTML in a DOM element, inserting singletons into head as needed |
| 1294 | + exports.renderHtml = function(html, el, dependencies) { |
| 1295 | + renderDependencies(dependencies) |
1292 | 1296 | return singletons.renderHtml(html, el);
|
1293 | 1297 | };
|
1294 | 1298 |
|
|
1326 | 1330 | if (dep.stylesheet) {
|
1327 | 1331 | var stylesheets = $.map(asArray(dep.stylesheet), function(stylesheet) {
|
1328 | 1332 | return $("<link rel='stylesheet' type='text/css'>")
|
1329 |
| - .attr("href", href + "/" + stylesheet); |
| 1333 | + .attr("href", href + "/" + escape(stylesheet)); |
1330 | 1334 | });
|
1331 | 1335 | $head.append(stylesheets);
|
1332 | 1336 | }
|
1333 | 1337 |
|
1334 | 1338 | if (dep.script) {
|
1335 | 1339 | var scripts = $.map(asArray(dep.script), function(scriptName) {
|
1336 |
| - return $("<script>").attr("src", href + "/" + scriptName); |
| 1340 | + return $("<script>").attr("src", href + "/" + escape(scriptName)); |
1337 | 1341 | });
|
1338 | 1342 | $head.append(scripts);
|
1339 | 1343 | }
|
1340 | 1344 |
|
| 1345 | + if (dep.attachment) { |
| 1346 | + // dep.attachment might be a single string, an array, or an object. |
| 1347 | + var attachments = dep.attachment; |
| 1348 | + if (typeof(attachments) === "string") |
| 1349 | + attachments = [attachments]; |
| 1350 | + |
| 1351 | + var attach = $.map(attachments, function(attachment, key) { |
| 1352 | + return $("<link rel='attachment'>") |
| 1353 | + .attr("id", dep.name + "-" + key + "-attachment") |
| 1354 | + .attr("href", href + "/" + escape(attachment)); |
| 1355 | + }); |
| 1356 | + $head.append(attach); |
| 1357 | + } |
| 1358 | + |
1341 | 1359 | if (dep.head) {
|
1342 | 1360 | var $newHead = $("<head></head>");
|
1343 | 1361 | $newHead.html(dep.head);
|
|
0 commit comments