Index: extensions/renderer/resources/guest_view/guest_view_attributes.js |
diff --git a/extensions/renderer/resources/guest_view/guest_view_attributes.js b/extensions/renderer/resources/guest_view/guest_view_attributes.js |
index a4c42b69b32a67c1437ff94f78d6e93843a70451..7bc33b81e24875e24ca0ad7ac2623fd8384381ab 100644 |
--- a/extensions/renderer/resources/guest_view/guest_view_attributes.js |
+++ b/extensions/renderer/resources/guest_view/guest_view_attributes.js |
@@ -9,9 +9,10 @@ |
// Default implementation of a GuestView attribute. |
function Attribute(name, view) { |
+ this.dirty = false; |
+ this.ignoreMutation = false; |
this.name = name; |
this.view = view; |
- this.ignoreMutation = false; |
this.defineProperty(); |
} |
@@ -21,6 +22,15 @@ Attribute.prototype.getValue = function() { |
return this.view.element.getAttribute(this.name) || ''; |
}; |
+// Retrieves and returns the attribute's value if it has been dirtied since |
+// the last time this method was called. Returns null otherwise. |
+Attribute.prototype.getValueIfDirty = function() { |
+ if (!this.dirty) |
+ return null; |
+ this.dirty = false; |
+ return this.getValue(); |
+}; |
+ |
// Sets the attribute's value. |
Attribute.prototype.setValue = function(value) { |
this.view.element.setAttribute(this.name, value || ''); |
@@ -51,6 +61,7 @@ Attribute.prototype.maybeHandleMutation = function(oldValue, newValue) { |
if (this.ignoreMutation) |
return; |
+ this.dirty = true; |
this.handleMutation(oldValue, newValue); |
}; |