Skip to content

Commit

Permalink
Merge branch 'v4-dev' into v4-dev-xmr-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
XhmikosR committed Aug 10, 2018
2 parents 340314a + 6b92321 commit e3acf7f
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 4 deletions.
52 changes: 52 additions & 0 deletions build/svgo.yml
Original file line number Diff line number Diff line change
@@ -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
12 changes: 10 additions & 2 deletions js/src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
12 changes: 12 additions & 0 deletions js/tests/unit/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = $('<div data-target="#7"></div>').appendTo($('#qunit-fixture'))
$('<div id="7" />').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'
Expand Down
2 changes: 1 addition & 1 deletion site/docs/4.1/assets/brand/bootstrap-outline.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion site/docs/4.1/assets/brand/bootstrap-punchout.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit e3acf7f

Please sign in to comment.