瀏覽代碼

Changed: Use `bind().toMany()` binding chain from `ObservableMixin`.

Maciej Gołaszewski 7 年之前
父節點
當前提交
2e6bbb9c31

+ 0 - 28
packages/ckeditor5-ui/src/bindings/bindonetomany.js

@@ -1,28 +0,0 @@
-/**
- * @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-/**
- * @module ui/bindings/getbindingtargets
- */
-
-export default function bindOneToMany( dropdownModel, boundProperty, collection, collectionProperty, callback ) {
-	dropdownModel.bind( boundProperty ).to(
-		// Bind to #isOn of each button...
-		...getBindingTargets( collection, collectionProperty ),
-		// ...and chose the title of the first one which #isOn is true.
-		callback
-	);
-}
-
-// Returns an array of binding components for
-// {@link module:utils/observablemixin~Observable#bind} from a set of iterable
-// buttons.
-//
-// @param {Iterable.<module:ui/button/buttonview~ButtonView>} buttons
-// @param {String} attribute
-// @returns {Array.<String>}
-function getBindingTargets( buttons, attribute ) {
-	return Array.prototype.concat( ...buttons.map( button => [ button, attribute ] ) );
-}

+ 0 - 37
packages/ckeditor5-ui/tests/bindings/bindonetomany.js

@@ -1,37 +0,0 @@
-/**
- * @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-import Model from '../../src/model';
-
-import bindOneToMany from './../../src/bindings/bindonetomany';
-
-describe( 'bindOneToMany()', () => {
-	it( 'binds observable property to collection property using callback', () => {
-		const model = new Model();
-		const observables = [
-			new Model( { property: false } ),
-			new Model( { property: false } ),
-			new Model( { property: false } )
-		];
-
-		bindOneToMany( model, 'property', observables, 'property',
-			( ...areEnabled ) => areEnabled.some( property => property )
-		);
-
-		expect( model.property ).to.be.false;
-
-		observables[ 0 ].property = true;
-
-		expect( model.property ).to.be.true;
-
-		observables[ 0 ].property = false;
-
-		expect( model.property ).to.be.false;
-
-		observables[ 1 ].property = true;
-
-		expect( model.property ).to.be.true;
-	} );
-} );