mirror of
https://github.com/google/blockly.git
synced 2026-01-07 00:50:27 +01:00
Use generics to derive SVG element type (#4036)
* Encapsulate type in a generic to automatically derive type of SVG element when using createSvgElement
This commit is contained in:
@@ -113,20 +113,22 @@ Blockly.createDom_ = function(container, options) {
|
||||
...
|
||||
</svg>
|
||||
*/
|
||||
var svg = Blockly.utils.dom.createSvgElement('svg', {
|
||||
'xmlns': Blockly.utils.dom.SVG_NS,
|
||||
'xmlns:html': Blockly.utils.dom.HTML_NS,
|
||||
'xmlns:xlink': Blockly.utils.dom.XLINK_NS,
|
||||
'version': '1.1',
|
||||
'class': 'blocklySvg',
|
||||
'tabindex': '0'
|
||||
}, container);
|
||||
var svg = Blockly.utils.dom.createSvgElement(
|
||||
Blockly.utils.dom.SvgElementType.SVG, {
|
||||
'xmlns': Blockly.utils.dom.SVG_NS,
|
||||
'xmlns:html': Blockly.utils.dom.HTML_NS,
|
||||
'xmlns:xlink': Blockly.utils.dom.XLINK_NS,
|
||||
'version': '1.1',
|
||||
'class': 'blocklySvg',
|
||||
'tabindex': '0'
|
||||
}, container);
|
||||
/*
|
||||
<defs>
|
||||
... filters go here ...
|
||||
</defs>
|
||||
*/
|
||||
var defs = Blockly.utils.dom.createSvgElement('defs', {}, svg);
|
||||
var defs = Blockly.utils.dom.createSvgElement(
|
||||
Blockly.utils.dom.SvgElementType.DEFS, {}, svg);
|
||||
// Each filter/pattern needs a unique ID for the case of multiple Blockly
|
||||
// instances on a page. Browser behaviour becomes undefined otherwise.
|
||||
// https://neil.fraser.name/news/2015/11/01/
|
||||
@@ -164,7 +166,7 @@ Blockly.createMainWorkspace_ = function(svg, options, blockDragSurface,
|
||||
|
||||
if (!wsOptions.hasCategories && wsOptions.languageTree) {
|
||||
// Add flyout as an <svg> that is a sibling of the workspace svg.
|
||||
var flyout = mainWorkspace.addFlyout('svg');
|
||||
var flyout = mainWorkspace.addFlyout(Blockly.utils.dom.SvgElementType.SVG);
|
||||
Blockly.utils.dom.insertAfter(flyout, svg);
|
||||
}
|
||||
if (wsOptions.hasTrashcan) {
|
||||
|
||||
Reference in New Issue
Block a user