diff --git a/build/svgo.yml b/build/svgo.yml new file mode 100644 index 000000000000..3d6a039d552c --- /dev/null +++ b/build/svgo.yml @@ -0,0 +1,52 @@ +# Usage: +# install svgo globally: `npm i -g svgo` +# svgo --config=build/svgo.yml --input=foo.svg + +# https://github.com/svg/svgo/blob/master/docs/how-it-works/en.md +# replace default config + +multipass: true +full: true + +# https://github.com/svg/svgo/blob/master/lib/svgo/js2svg.js#L6 for more config options + +js2svg: + pretty: true + indent: 2 + +plugins: + - cleanupAttrs: true + - cleanupEnableBackground: true + - cleanupIDs: true + - cleanupListOfValues: true + - cleanupNumericValues: true + - collapseGroups: true + - convertColors: true + - convertPathData: true + - convertShapeToPath: true + - convertStyleToAttrs: true + - convertTransform: true + - inlineStyles: true + - mergePaths: true + - minifyStyles: true + - moveElemsAttrsToGroup: true + - moveGroupAttrsToElems: true + - removeComments: true + - removeDesc: true + - removeDoctype: true + - removeEditorsNSData: true + - removeEmptyAttrs: true + - removeEmptyContainers: true + - removeEmptyText: true + - removeHiddenElems: true + - removeMetadata: true + - removeNonInheritableGroupAttrs: true + - removeTitle: true + - removeUnknownsAndDefaults: true + - removeUnusedNS: true + - removeUselessDefs: true + - removeUselessStrokeAndFill: true + - removeViewBox: false + - removeXMLNS: false + - removeXMLProcInst: false + - sortAttrs: true diff --git a/js/src/util.js b/js/src/util.js index eb98d449c82a..3008c227851a 100644 --- a/js/src/util.js +++ b/js/src/util.js @@ -77,12 +77,20 @@ const Util = (($) => { getSelectorFromElement(element) { let selector = element.getAttribute('data-target') + let method = 'querySelector' + if (!selector || selector === '#') { - selector = element.getAttribute('href') || '' + selector = (element.getAttribute('href') || '').trim() + } + + const validSelector = selector + if (selector.charAt(0) === '#') { + selector = selector.substr(1) + method = 'getElementById' } try { - return document.querySelector(selector) ? selector : null + return document[method](selector) ? validSelector : null } catch (err) { return null } diff --git a/js/tests/unit/util.js b/js/tests/unit/util.js index 37327b8681ee..49252701a501 100644 --- a/js/tests/unit/util.js +++ b/js/tests/unit/util.js @@ -20,6 +20,18 @@ $(function () { assert.strictEqual(Util.getSelectorFromElement($el2[0]), null) }) + QUnit.test('Util.getSelectorFromElement should use getElementById', function (assert) { + assert.expect(2) + + var spy = sinon.spy(document, 'getElementById') + + var $el = $('
').appendTo($('#qunit-fixture')) + $('
').appendTo($('#qunit-fixture')) + + assert.strictEqual(Util.getSelectorFromElement($el[0]), '#7') + assert.ok(spy.called) + }) + QUnit.test('Util.typeCheckConfig should thrown an error when a bad config is passed', function (assert) { assert.expect(1) var namePlugin = 'collapse' diff --git a/site/docs/4.1/assets/brand/bootstrap-outline.svg b/site/docs/4.1/assets/brand/bootstrap-outline.svg index 215be0585242..f331db63f305 100644 --- a/site/docs/4.1/assets/brand/bootstrap-outline.svg +++ b/site/docs/4.1/assets/brand/bootstrap-outline.svg @@ -1,4 +1,4 @@ - + diff --git a/site/docs/4.1/assets/brand/bootstrap-punchout.svg b/site/docs/4.1/assets/brand/bootstrap-punchout.svg index 9f4f529ccd9f..8538ee95c8ca 100644 --- a/site/docs/4.1/assets/brand/bootstrap-punchout.svg +++ b/site/docs/4.1/assets/brand/bootstrap-punchout.svg @@ -1,4 +1,4 @@ - +