Skip to content

Commit

Permalink
File Block: Set the download attribute as empty (#10948)
Browse files Browse the repository at this point in the history
  • Loading branch information
Copons authored Oct 23, 2018
1 parent 9a80b98 commit f0831a1
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 21 deletions.
7 changes: 2 additions & 5 deletions packages/block-library/src/file/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { createBlobURL } from '@wordpress/blob';
import { createBlock } from '@wordpress/blocks';
import { select } from '@wordpress/data';
import { RichText } from '@wordpress/editor';
import { create, getTextContent } from '@wordpress/rich-text';

/**
* Internal dependencies
Expand Down Expand Up @@ -218,10 +217,8 @@ export const settings = {
<a
href={ href }
className="wp-block-file__button"
// ensure download attribute is still set when fileName
// is undefined. Using '' here as `true` still leaves
// the attribute unset.
download={ getTextContent( create( { html: fileName } ) ) }
// Using '' here as `true` leaves the attribute unset.
download=""
>
<RichText.Content
value={ downloadButtonText }
Expand Down
4 changes: 2 additions & 2 deletions test/integration/full-content/fixtures/core__categories.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"name": "core/categories",
"isValid": true,
"attributes": {
"showPostCounts": false,
"displayAsDropdown": false,
"showHierarchy": false
"showHierarchy": false,
"showPostCounts": false
},
"innerBlocks": [],
"originalContent": ""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<!-- wp:file {"href":"http://localhost:8888/wp-content/uploads/2018/05/keycodes.js","showDownloadButton":true,"id":176} -->
<div class="wp-block-file"><a href="http://localhost:8888/wp-content/uploads/2018/05/keycodes.js" target="_blank" rel="noreferrer noopener">6546</a><a href="http://localhost:8888/wp-content/uploads/2018/05/keycodes.js" class="wp-block-file__button" download="6546">Download</a></div>
<div class="wp-block-file"><a href="http://localhost:8888/wp-content/uploads/2018/05/keycodes.js" target="_blank" rel="noreferrer noopener">6546</a><a href="http://localhost:8888/wp-content/uploads/2018/05/keycodes.js" class="wp-block-file__button" download="">Download</a></div>
<!-- /wp:file -->
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
"downloadButtonText": "Download"
},
"innerBlocks": [],
"originalContent": "<div class=\"wp-block-file\"><a href=\"http://localhost:8888/wp-content/uploads/2018/05/keycodes.js\" target=\"_blank\" rel=\"noreferrer noopener\">6546</a><a href=\"http://localhost:8888/wp-content/uploads/2018/05/keycodes.js\" class=\"wp-block-file__button\" download=\"6546\">Download</a></div>"
"originalContent": "<div class=\"wp-block-file\"><a href=\"http://localhost:8888/wp-content/uploads/2018/05/keycodes.js\" target=\"_blank\" rel=\"noreferrer noopener\">6546</a><a href=\"http://localhost:8888/wp-content/uploads/2018/05/keycodes.js\" class=\"wp-block-file__button\" download=\"\">Download</a></div>"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"id": 176
},
"innerBlocks": [],
"innerHTML": "\n<div class=\"wp-block-file\"><a href=\"http://localhost:8888/wp-content/uploads/2018/05/keycodes.js\" target=\"_blank\" rel=\"noreferrer noopener\">6546</a><a href=\"http://localhost:8888/wp-content/uploads/2018/05/keycodes.js\" class=\"wp-block-file__button\" download=\"6546\">Download</a></div>\n"
"innerHTML": "\n<div class=\"wp-block-file\"><a href=\"http://localhost:8888/wp-content/uploads/2018/05/keycodes.js\" target=\"_blank\" rel=\"noreferrer noopener\">6546</a><a href=\"http://localhost:8888/wp-content/uploads/2018/05/keycodes.js\" class=\"wp-block-file__button\" download=\"\">Download</a></div>\n"
},
{
"blockName": null,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<!-- wp:file {"id":176,"href":"http://localhost:8888/wp-content/uploads/2018/05/keycodes.js"} -->
<div class="wp-block-file"><a href="http://localhost:8888/wp-content/uploads/2018/05/keycodes.js" target="_blank" rel="noreferrer noopener">6546</a><a href="http://localhost:8888/wp-content/uploads/2018/05/keycodes.js" class="wp-block-file__button" download="6546">Download</a></div>
<div class="wp-block-file"><a href="http://localhost:8888/wp-content/uploads/2018/05/keycodes.js" target="_blank" rel="noreferrer noopener">6546</a><a href="http://localhost:8888/wp-content/uploads/2018/05/keycodes.js" class="wp-block-file__button" download="">Download</a></div>
<!-- /wp:file -->
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[
{
"attrs": {},
"blockName": null,
"attrs": {},
"innerBlocks": [],
"innerHTML": "Testing freeform block with some\n<div class=\"wp-some-class\">\n\tHTML <span style=\"color: red;\">content</span>\n</div>\n"
}
Expand Down
6 changes: 3 additions & 3 deletions test/integration/full-content/fixtures/core__missing.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"name": "core/missing",
"isValid": true,
"attributes": {
"originalContent": "<!-- wp:unregistered/example {\"attr1\":\"One\",\"attr2\":\"Two\"} -->\n<p>Testing missing block with some</p>\n<div class=\"wp-some-class\">\n\tHTML <span style=\"color: red;\">content</span>\n</div>\n<!-- /wp:unregistered/example -->",
"originalName": "unregistered/example",
"originalUndelimitedContent": "<p>Testing missing block with some</p>\n<div class=\"wp-some-class\">\n\tHTML <span style=\"color: red;\">content</span>\n</div>"
"originalName": "unregistered/example",
"originalUndelimitedContent": "<p>Testing missing block with some</p>\n<div class=\"wp-some-class\">\n\tHTML <span style=\"color: red;\">content</span>\n</div>",
"originalContent": "<!-- wp:unregistered/example {\"attr1\":\"One\",\"attr2\":\"Two\"} -->\n<p>Testing missing block with some</p>\n<div class=\"wp-some-class\">\n\tHTML <span style=\"color: red;\">content</span>\n</div>\n<!-- /wp:unregistered/example -->"
},
"innerBlocks": [],
"originalContent": "<!-- wp:unregistered/example {\"attr1\":\"One\",\"attr2\":\"Two\"} -->\n<p>Testing missing block with some</p>\n<div class=\"wp-some-class\">\n\tHTML <span style=\"color: red;\">content</span>\n</div>\n<!-- /wp:unregistered/example -->"
Expand Down
12 changes: 6 additions & 6 deletions test/integration/full-content/fixtures/core__missing.parsed.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
{
"blockName": "unregistered/example",
"attrs": {
"attr1": "One",
"attr2": "Two"
},
"attr1": "One",
"attr2": "Two"
},
"innerBlocks": [],
"innerHTML": "\n<p>Testing missing block with some</p>\n<div class=\"wp-some-class\">\n\tHTML <span style=\"color: red;\">content</span>\n</div>\n"
},
{
"blockName": null,
"attrs": {},
"innerBlocks": [],
"blockName": null,
"attrs": {},
"innerBlocks": [],
"innerHTML": "\n"
}
]

0 comments on commit f0831a1

Please sign in to comment.