Make WordPress Core

Opened 11 years ago

Closed 11 years ago

#29130 closed defect (bug) (wontfix)

wp.mce.View.extend no longer working as expected

Reported by: tolnem's profile tolnem Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.0
Component: TinyMCE Keywords:
Focuses: javascript Cc:

Description

I have a plugin that uses wp.mce.views.register to parse shortcodes and render a placeholder in the wysiwyg editor.

In 3.9.1, I was using the syntax View: wp.mce.View.extend({...}) to create the view that is rendered in the editor, but this no longer works under 4.0. The default wp.mce.View object is used instead.

In 4.0 beta, I I instead need to use View: _.extend( {}, wp.mce.View, {...}) to get the same effect that I used to get using wp.mce.View.extend. The underscore based syntax is however not backwards compatible with 3.9.1, where it breaks with the javascript error "g.View is not a constructor".

Change History (4)

#1 @helen
11 years ago

  • Milestone changed from Awaiting Review to 4.0

Should look into this.

#2 @iseulde
11 years ago

Instead of View: wp.mce.View.extend( {...} ), you should now just do View: {...} as it will extend when registering. Note that that file is still marked as experimental and not backwards compatible.
We can consider reverting that change though... it was introduced here: [28680].

Do you have a link to the plugin?

#3 @tolnem
11 years ago

I have noted that the code that I'm extending is experimental and still under development, and I am happy to handle the change on my side if necessary.

I just reported this as a bug in case the backwards compatibility break wasn't intended, and because it seemed to me that the wp.mce.View.extend function now has no effect. Changing the code to just View: {...} works fine and feels cleaner. The number of installs I have this on isn't larger than that I can handle a backwards compatibility break, so for the sake of having cleaner code going forward I would not want you to revert this unless it really broke something that was expected to work.

The plugin is part of a commercial product, so I am not able to share it with you.

#4 @iseulde
11 years ago

  • Milestone 4.0 deleted
  • Resolution set to wontfix
  • Status changed from new to closed

Okay, let's leave it as it is now.

Note: See TracTickets for help on using tickets.