diff --git a/wp-includes/class-wp-admin-bar.php b/wp-includes/class-wp-admin-bar.php
index 49986ac..3386408 100644
--- a/wp-includes/class-wp-admin-bar.php
+++ b/wp-includes/class-wp-admin-bar.php
@@ -100,6 +100,7 @@ class WP_Admin_Bar {
 	 *
 	 * @since 3.1.0
 	 * @since 4.5.0 Added the ability to pass 'lang' and 'dir' meta data.
+	 * @since 4.8.x Added the ability to arbitrary HTML attributes as meta data
 	 * @access public
 	 *
 	 * @param array $args {
@@ -110,8 +111,12 @@ class WP_Admin_Bar {
 	 *     @type string $parent Optional. ID of the parent node.
 	 *     @type string $href   Optional. Link for the item.
 	 *     @type bool   $group  Optional. Whether or not the node is a group. Default false.
-	 *     @type array  $meta   Meta data including the following keys: 'html', 'class', 'rel', 'lang', 'dir',
-	 *                          'onclick', 'target', 'title', 'tabindex'. Default empty.
+	 *     @type array  $meta   {
+	 *          Optional. HTML attributes (except for 'html', see below)
+	 *
+	 *          @type string $html Arbitrary HTML markup output after the node
+	 *          @type string xxx Arbitrary HTML attribute
+	 *     }
 	 * }
 	 */
 	public function add_node( $args ) {
@@ -494,42 +499,43 @@ class WP_Admin_Bar {
 		if ( $menuclass )
 			$menuclass = ' class="' . esc_attr( trim( $menuclass ) ) . '"';
 
+		if ( !isset( $node->meta['class'] ) ) {
+			$node->meta['class'] = 'ab-item';
+		} else {
+			$node->meta['class'] .= ' ab-item';
+		}
+			
+		if ( $has_link ) {
+			$node->meta['class'] .= ' ab-empty-item';
+		}
 		?>
 
 		<li id="<?php echo esc_attr( 'wp-admin-bar-' . $node->id ); ?>"<?php echo $menuclass; ?>><?php
 			if ( $has_link ):
-				?><a class="ab-item"<?php echo $aria_attributes; ?> href="<?php echo esc_url( $node->href ) ?>"<?php
-					if ( ! empty( $node->meta['onclick'] ) ) :
-						?> onclick="<?php echo esc_js( $node->meta['onclick'] ); ?>"<?php
-					endif;
-				if ( ! empty( $node->meta['target'] ) ) :
-					?> target="<?php echo esc_attr( $node->meta['target'] ); ?>"<?php
-				endif;
-				if ( ! empty( $node->meta['title'] ) ) :
-					?> title="<?php echo esc_attr( $node->meta['title'] ); ?>"<?php
-				endif;
-				if ( ! empty( $node->meta['rel'] ) ) :
-					?> rel="<?php echo esc_attr( $node->meta['rel'] ); ?>"<?php
-				endif;
-				if ( ! empty( $node->meta['lang'] ) ) :
-					?> lang="<?php echo esc_attr( $node->meta['lang'] ); ?>"<?php
-				endif;
-				if ( ! empty( $node->meta['dir'] ) ) :
-					?> dir="<?php echo esc_attr( $node->meta['dir'] ); ?>"<?php
-				endif;
-				?>><?php
+			?><a<?php echo $aria_attributes; ?> href="<?php echo esc_url( $node->href ) ?>"<?php
+				foreach ( $node->meta as $attr => $value ) {
+					if ( in_array($attr, array( 'aria-haspopup', 'href', 'html', ) ) || empty( $value ) ) {
+						continue ;
+					}
+
+					// @todo it would probably be a good idea to sanitize the attribute name
+					//    AFAIK core doesn't current contain a func to do that, should one be added?
+					echo sprintf (" $attr=\"%s\"",
+						stripos ( $attr, 'on' ) === 0 ? esc_js( $value ) : esc_attr( $value ) );
+			}
+			?>><?php
 			else:
-				?><div class="ab-item ab-empty-item"<?php echo $aria_attributes;
-				if ( ! empty( $node->meta['title'] ) ) :
-					?> title="<?php echo esc_attr( $node->meta['title'] ); ?>"<?php
-				endif;
-				if ( ! empty( $node->meta['lang'] ) ) :
-					?> lang="<?php echo esc_attr( $node->meta['lang'] ); ?>"<?php
-				endif;
-				if ( ! empty( $node->meta['dir'] ) ) :
-					?> dir="<?php echo esc_attr( $node->meta['dir'] ); ?>"<?php
-				endif;
-				?>><?php
+					?><div<?php echo $aria_attributes;
+				foreach ( $node->meta as $attr => $value ) {
+					if ( in_array($attr, array( 'aria-haspopup', 'html', ) ) || empty( $value ) ) {
+						continue ;
+					}
+
+					// @todo it would probably be a good idea to sanitize the attribute name
+					//    AFAIK core doesn't current contain a func to do that, should one be added?
+					echo sprintf (" $attr=\"%s\"",
+						stripos ( $attr, 'on' ) === 0 ? esc_js( $value ) : esc_attr( $value ) );
+			}?>><?php
 			endif;
 
 			echo $node->title;
