diff --git a/rollup.test.js b/rollup.test.js index a8d882e9..8e7f338d 100644 --- a/rollup.test.js +++ b/rollup.test.js @@ -3,7 +3,7 @@ import commonjs from 'rollup-plugin-commonjs' import multiEntry from 'rollup-plugin-multi-entry' export default { - input: 'test/*.tests.js', + input: 'test/y-xml.tests.js', name: 'y-tests', sourcemap: true, output: { @@ -11,12 +11,12 @@ export default { format: 'umd' }, plugins: [ + multiEntry(), nodeResolve({ main: true, module: true, browser: true }), - commonjs(), - multiEntry() + commonjs() ] } diff --git a/src/Type/y-xml/YXmlFragment.js b/src/Type/y-xml/YXmlFragment.js index 74148b91..884f3853 100644 --- a/src/Type/y-xml/YXmlFragment.js +++ b/src/Type/y-xml/YXmlFragment.js @@ -143,6 +143,23 @@ export default class YXmlFragment extends YArray { } setDomFilter (f) { this._domFilter = f + let attributes = new Map() + if (this.getAttributes !== undefined) { + let attrs = this.getAttributes() + for (let key in attrs) { + attributes.set(key, attrs[key]) + } + } + let result = this._domFilter(this.nodeName, new Map(attributes)) + if (result === null) { + this._delete(this._y) + } else { + attributes.forEach((value, key) => { + if (!result.has(key)) { + this.removeAttribute(key) + } + }) + } this.forEach(xml => { xml.setDomFilter(f) })