title: Wordpress Gutenberg blocks - Extension of core/code and deprecated settings gives error
body: <p>At first I just wanted to extend one of Wordpress Gutenberg blocks. I chose the 'core/code' block. I added the h2 tag for a title after the default content, which worked fine. Then I decided to change the h2 tag to p tag. As I understand I need to add deprecated array to settings object. I did this but I am getting this error:</p>
  
  <pre><code>Content generated by `save` function:
  &lt;pre&gt;&lt;code&gt;undefined&lt;/code&gt;&lt;/pre&gt;&lt;h2&gt;&lt;/h2&gt;&lt;p&gt;&lt;/p&gt;
  Content retrieved from post body:
  &lt;pre class="wp-block-code"&gt;&lt;code&gt;&amp;lt;p&gt;sdsd&amp;lt;/p&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h2&gt;changed!&lt;/h2&gt;
  </code></pre>
  
  <p>My code:</p>
  
  <pre><code>const enableExtendOnBlocks = [
      'core/code',
  ];
  
  function addAttributes( settings, name ) {
  
      if ( ! enableExtendOnBlocks.includes( name ) ) {
          return settings;
      }
  
       if( typeof settings.attributes !== 'undefined' ){
  
          settings.attributes = Object.assign( settings.attributes, {
              vista:{
                  type: 'string',
                  default: 'vista',
                  source: 'html',
                  selector: 'p',
              }
          });
  
          settings.title = 'My Code';
  
          const oldAtt = {
               ...settings.attributes,
              vista: {
                  type: 'string',
                  source: 'html',
                   selector: 'h2',
                  default: 'vista',
              },
           };
  
          settings.deprecated = [
              {
                  attributes: oldAtt,
                  save: function (oldAtt) {
                      return (
                          &lt;&gt;
                              &lt;pre&gt;
                                  &lt;code&gt;{ escape( oldAtt.content ) }&lt;/code&gt;
                              &lt;/pre&gt;
                              &lt;RichText.Content
                                  tagName="h2"
                                  value={oldAtt.vista}
                              /&gt;
                          &lt;/&gt;
                      );
                  },
              }
          ];
      }
  
      return settings;
  }
  
  wp.hooks.addFilter(
      'blocks.registerBlockType',
      'extend-block-example/custom-attributes',
      addAttributes
  );
  
  
  const withInspectorControls =  createHigherOrderComponent( ( BlockEdit ) =&gt; {
  
      return ( props ) =&gt; {
  
          if ( ! enableExtendOnBlocks.includes( props.name ) ) {
              return &lt;BlockEdit { ...props } /&gt;;
           }
  
          const onChangeVista = (vista) =&gt; {
              props.setAttributes({
                  vista: vista
              });
          };
  
          return (
              &lt;Fragment&gt;
                  &lt;BlockEdit { ...props } /&gt;
                  &lt;RichText
                      tagName="p"
                      formattingControls={[]}
                      value={props.attributes.vista}
                      onChange={(vista) =&gt; onChangeVista(vista)}
                  /&gt;
              &lt;/Fragment&gt;
          );
      };
   }, "withInspectorControl" );
  
  wp.hooks.addFilter( 'editor.BlockEdit', 'my-plugin/with-inspector-controls', withInspectorControls );
  
  
  function wpse298225GallerySaveElement( element, blockType, attributes ) {
      if ( blockType.name !== 'core/code' ) {
         return element;
      }
  
      return (
          &lt;&gt;
              {element}
              &lt;RichText.Content
                  tagName="p"
                  value={attributes.vista}
              /&gt;
          &lt;/&gt;
      );
  }
  
  
   wp.hooks.addFilter(
       'blocks.getSaveElement',
       'wpse-298225',
       wpse298225GallerySaveElement
   );
  </code></pre>
  
  <p>What am I doing wrong?</p>