diff options
| author | Olivier Dony <odo@openerp.com> | 2017-05-31 19:28:20 +0200 |
|---|---|---|
| committer | Olivier Dony <odo@openerp.com> | 2017-05-31 19:28:20 +0200 |
| commit | 156e9d00164b58cbafb7dba9018df194391fc0be (patch) | |
| tree | 644df366a8d221bc02e2c7774616331d826a8e90 /addons/web_editor/static/src | |
| parent | e61c442f18cc1d21da3693003a5d54d69a95771d (diff) | |
| parent | 75e03c0f7692a112e1b0fa33267f4939363f3871 (diff) | |
[MERGE] Forward-port 9.0 up to 75e03c0f7692a112e1b0fa33267f4939363f3871
Diffstat (limited to 'addons/web_editor/static/src')
| -rw-r--r-- | addons/web_editor/static/src/js/snippets.editor.js | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/addons/web_editor/static/src/js/snippets.editor.js b/addons/web_editor/static/src/js/snippets.editor.js index 51cc5a31615..727b4818734 100644 --- a/addons/web_editor/static/src/js/snippets.editor.js +++ b/addons/web_editor/static/src/js/snippets.editor.js @@ -144,7 +144,7 @@ var BuildingBlock = Widget.extend({ return $from.closest(selector, parentNode); }, all: function ($from) { - return $from ? $from.find(selector) : $(selector); + return $from ? cssFind($from, selector) : $(selector); }, is: function ($from) { return $from.is(selector); @@ -167,15 +167,31 @@ var BuildingBlock = Widget.extend({ }); }, all: is_children ? function ($from) { - return ($from || self.$editable).find(selector); + return cssFind($from || self.$editable, selector); } : function ($from) { - return $from ? $from.find(selector) : self.$editable.filter(selector).add(self.$editable.find(selector)); + $from = $from || self.$editable; + return $from.filter(selector).add(cssFind($from, selector)); }, is: function ($from) { return $from.is(selector); } }; } + + /** + * jQuery find function behavior is: + * $('A').find('A B') <=> $('A A B') + * The searches behavior to find options' DOM needs to be + * $('A').find('A B') <=> $('A B') + * This is what this function does. + * + * @param {jQuery} $from - the jQuery element(s) from which to search + * @param {string} selector - the CSS selector to match + * @returns {jQuery} + */ + function cssFind($from, selector) { + return $from.find('*').filter(selector); + } }, fetch_snippet_templates: function () { |
