Procházet zdrojové kódy

Minor fixes in view.Matcher and view.Element#findAncestor.

Szymon Kupś před 9 roky
rodič
revize
ac25561568

+ 3 - 3
packages/ckeditor5-engine/src/view/element.js

@@ -575,14 +575,14 @@ export default class Element extends Node {
 	 * Provided patterns should be compatible with {@link engine.view.Matcher Matcher} as it is used internally.
 	 *
 	 * @see engine.view.Matcher
-	 * @param {Object|String|RegExp|function} patterns Patterns used to match correct ancestor. See {@link engine.view.Matcher}.
-	 * @return {engine.view.Element|null} Found element or `null` if no matching ancestor was found.
+	 * @param {Object|String|RegExp|Function} patterns Patterns used to match correct ancestor. See {@link engine.view.Matcher}.
+	 * @returns {engine.view.Element|null} Found element or `null` if no matching ancestor was found.
 	 */
 	findAncestor( ...patterns ) {
 		const matcher = new Matcher( ...patterns );
 		let parent = this.parent;
 
-		while ( parent !== null ) {
+		while ( parent ) {
 			if ( matcher.match( parent ) ) {
 				return parent;
 			}

+ 3 - 3
packages/ckeditor5-engine/src/view/matcher.js

@@ -86,7 +86,7 @@ export default class Matcher {
 	 *
 	 * 		matcher.add( 'div', { class: 'foobar' } );
 	 *
-	 * @param {Object|String|RegExp|function} pattern Object describing pattern details. If string or regular expression
+	 * @param {Object|String|RegExp|Function} pattern Object describing pattern details. If string or regular expression
 	 * is provided it will be used to match element's name. Pattern can be also provided in a form
 	 * of a function - then this function will be called with each {@link engine.view.Element element} as a parameter.
 	 * Function's return value will be stored under `match` key of the object returned from
@@ -139,7 +139,7 @@ export default class Matcher {
 	 * @param {...core.view.Element} element View element to match against stored patterns.
 	 * @returns {Object|null} result
 	 * @returns {core.view.Element} result.element Matched view element.
-	 * @returns {Object|String|RegExp|function} result.pattern Pattern that was used to find matched element.
+	 * @returns {Object|String|RegExp|Function} result.pattern Pattern that was used to find matched element.
 	 * @returns {Object} result.match Object representing matched element parts.
 	 * @returns {Boolean} [result.match.name] True if name of the element was matched.
 	 * @returns {Array} [result.match.attribute] Array with matched attribute names.
@@ -212,7 +212,7 @@ export default class Matcher {
 // If element cannot be matched to provided pattern - returns `null`.
 //
 // @param {engine.view.Element} element
-// @param {Object|String|RegExp|function} pattern
+// @param {Object|String|RegExp|Function} pattern
 // @returns {Object|null} Returns object with match information or null if element is not matching.
 function isElementMatching( element, pattern ) {
 	// If pattern is provided as function - return result of that function;